|
Dears:
I want to read some data from file and store it in array. I face some problems, need help from you all^^
1.I use fscanf(...) to read. but i failed to detect the end of line.
2.6.2478916055375
When i read this number using
Long lBuf;
fscanf(pfile, "%ld", &lBuf);
It fails. The result is lBuf=6.
Is there another way to read it?
Thanks^^
|
|
|
|
|
fscanf(pfile, "%l\n", &lBuf); perhaps...
TOXCCT >>> GEII power
|
|
|
|
|
From the following code, why after the program terminates,
m_listSampleName[i] for i=0 to m_nSampleNumber share the same datas?
I have tried to debug, but I don't find out where is the error?
Please help. Thanks a lot before.
m_nSampleNumber = 0;
while(!in.eof())
{
in>>strBuf;
if(strcmp(strBuf,"END"))
{
m_listSampleName[m_nSampleNumber] = strBuf;
m_nSampleNumber++;
}
else
break;
}
|
|
|
|
|
FYI,
char* m_listSampleName[MAX_GENE_NUMBER];
Is the error on the member declaration?
|
|
|
|
|
"%ld" is asking for a long interger value; therefore, it returns an interger value (what you asked for).
double d;
fscanf(pfile,"%f",&d);
result should be d=6.2478916055375.
INTP
|
|
|
|
|
Dear all,
I am new for this site as well as for VC++. I recently got a job
I am working on data compression/decompression. Be very much clear Not file compression/decompression.I am to compress the data cluster by cluster of any harddisk. how can i compress a cluster into bytes or sector? I have no clue about it
All suggestion are welcomeed .
Thanks
snav
|
|
|
|
|
this is a crap idea! if you compress a cluster then the cluster is not full anymore. if you move other data in there then, then you need much time to decompress the whole thing again... in my opinion a silly idea, not worth the work on it. by the way, coding this is quite complicated, too, because it has to run as a storage filter driver.
Don't try it, just do it!
|
|
|
|
|
Hi
Alexender
Thanks for the suggestion and replay.
I agree with u but what i just want to do. I read a cluster using ReadFile() function and keep it in buffer . Now my question is how to compress this data which is in buffer so that if i write it any other place as a backup. It takes less memory space in HDD or any other storing device.
I am to compress files but cluster by cluster because i want to store the backup of this file in bytes(row) form not in file form [compressed file takes clusters again wastage of space ] .
This might be crap idea. But u would be able to help me , i'll be thankfull.
Now Ball is in your goal
|
|
|
|
|
I've got HUGE problems with floating point precision lost
in the following code:
- s*(a.y-c.y) - h*(b.y-c.y)
where
s = h = 0.333....
c.y = 0.675
a.y = b.y = 0
The result is about 5.e-17 (as I understand, NAN).
How to overcome the problem, forex
find out that precision lost occured.
Thank you for help, A. M.
gp123456
|
|
|
|
|
try a.y = b.y = 0.0;
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
try a.y = b.y = 0.0;
Of cource, a.y & b.y are doubles too!
So read a.y = 0.0, b.y = 0.0
Suppose you haven't understood my question:
precision lost is a result of existing in my
program double values with infinite part after
floating point, e.g. that
s = 0.3333... (infinite 3's after floating point)
&
h = 0.3333... (infinite 3's after floating point).
|
|
|
|
|
could you give a piece of code (the equation calculation for example) ?
TOXCCT >>> GEII power
|
|
|
|
|
Loss of precision is an inherent problem with floating-point numbers (float and double ). You should never test for equality between two float s/double s because of this, but instead test that the difference is less than some threshhold.
To get around this, you'll need to use some alternate means of manipulating floating-point numbers.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
"Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"
-- Rico Mariani, CLR perf guy
|
|
|
|
|
Michael Dunn wrote:
you'll need to use some alternate means of manipulating floating-point numbers.
You right! But I'd like to know which one exactly. Some useful links are welcomed.
|
|
|
|
|
It would be wise to compare the result from above formula with result from
-s*ay - h*by + cy*(s+h)
and if results dont compare have some kind of error recovery. if calculations are not too many and time bound most wise programmers(not me) calculate with 2 formulae and compare results.
|
|
|
|
|
Mike is correct. However, there is something more going on.
Are you sure that "s == h"? Even with floating point imprecision, I don't see how the two parts of the expression won't cancel each other out. I tried this with initializing h and s to 1.0/3.0 and it worked properly.
However, generally speaking, checking for "== 0" with floating point numbers is a VERY bad idea. Usually you need to check if "- epsilon < x < epsilon" where epsilon is your tolerance for imprecision.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
You know, I'm not checking if h==s, I just execute the code.
I found out that h==s using debugger.
I'm interested in way to find out that precision lost occured in
MS VisualC++ 7.0.
|
|
|
|
|
Follow the link below, you will know why there is loss in precision:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_why_floating_point_numbers_may_lose_precision.asp
To solve the problem, there is a free library called MAPM which can help you to calculate precisly:
http://www.tc.umn.edu/~ringx004/mapm-main.html
Hope that it can help.
|
|
|
|
|
The problem solved itself!
I've changed computer (from Celeron 800 MHz to Celeron 2GHz),
and the equation doesn't affects the results!
Anybody knows the reason?
I heard something about bugs in FPU of P300-1000...
Anyway, thank you very much for links, Hing.
They are very useful for me.
|
|
|
|
|
Hi!
I'm looking for a special algorithm, either a one ready-to-use or at least a description of how to begin:
Say I have a image file (.jpg), I want to analyze what color/s has/have the biggest potion - say I have an image with many gray tones, then I want to get the RGB value of this gray color, or an average of the most used gray tones in the picture.
I hope my question was clear enough
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
The easiest way is to build a histogram - count how many appearances each color has.
|
|
|
|
|
why dont you add the r, g and b values of every pixel and compare the sum?
Don't try it, just do it!
|
|
|
|
|
There are some small programs of examining bitmaps at www.flounder.com, you'll need to convert them to .bmp first.
If nothing else, they may give you a good start.
Good luck!
INTP
|
|
|
|
|
Thanks, I will try some of your suggestions
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hallo!
I'm a beginner with MFC... can somebody tell me how can I read 3 parameters from a *.txt into a Class.
//actually it would be 3 points of an triangle and I would load the co-ordinates of Points from the file
<br />
typedef int Point[2];<br />
<br />
class Point : public CObject<br />
{<br />
public:<br />
<br />
<br />
Points(){};<br />
<br />
Pont SummPoints[5];<br />
int PointNumm;<br />
bool TriangleTest (Pont a, Pont b, Pont c) <br />
{<br />
double long1 = sqrt((a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]));<br />
double long2 = sqrt((a[0]-c[0])*(a[0]-c[0]) + (a[1]-c[1])*(a[1]-c[1]));<br />
double long3 = sqrt((c[0]-b[0])*(c[0]-b[0]) + (c[1]-b[1])*(c[1]-b[1]));<br />
if (long1>= (long2+long3)) return false;<br />
<br />
}<br />
};
Muad-Dib
mailto:adamo_piar@freemail.hu
Made in Hungary
|
|
|
|