Click here to Skip to main content
15,889,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ image compression LZW algorithm??? Pin
Hamid_RT29-Apr-08 1:59
Hamid_RT29-Apr-08 1:59 
Questionunexpected behaviour of 'atof' and 'strtod' Pin
Member 361100228-Apr-08 6:03
Member 361100228-Apr-08 6:03 
GeneralRe: unexpected behaviour of 'atof' and 'strtod' Pin
David Crow28-Apr-08 6:13
David Crow28-Apr-08 6:13 
GeneralRe: unexpected behaviour of 'atof' and 'strtod' Pin
cagespear28-Apr-08 8:09
cagespear28-Apr-08 8:09 
GeneralRe: unexpected behaviour of 'atof' and 'strtod' Pin
David Crow28-Apr-08 8:12
David Crow28-Apr-08 8:12 
AnswerRe: unexpected behaviour of 'atof' and 'strtod' Pin
Michael Dunn28-Apr-08 15:03
sitebuilderMichael Dunn28-Apr-08 15:03 
GeneralRe: unexpected behaviour of 'atof' and 'strtod' Pin
Saurabh.Garg28-Apr-08 15:54
Saurabh.Garg28-Apr-08 15:54 
AnswerRe: unexpected behaviour of 'atof' and 'strtod' Pin
Ozer Karaagac28-Apr-08 16:03
professionalOzer Karaagac28-Apr-08 16:03 
Simply, this is related with binary representation of floating point numbers.
Member 3611002 wrote:
The results of both d and d1 are 37.619999999999997 (unexpected)
what do i do to get d=37.62 and d1=37.62

This is normal and there is nothing to do for a double type. if you format that number back using format string %.2f, you will get 37.62 again.

I'll try to comment on, shortly.
As you may know, double is a 64 bit floating point number. There are some special formats (standards defined by IEEE in this case) to store it in memory. It consists of 3 parts; sign (1), exponent (11), significand (52 bits). There are also special rules for storing exponent and significand. Most important one, exponent part is two's exponent, not ten's. Moreover, some operations (i.e. rounding and normalization) have been applied to a floating point number after every operation. After all, it is stored as nearest possible value fitting into these rules.
QuestionHow to get rid of this ERROR Pin
pl_kode28-Apr-08 3:38
pl_kode28-Apr-08 3:38 
GeneralRe: How to get rid of this ERROR Pin
CPallini28-Apr-08 3:43
mveCPallini28-Apr-08 3:43 
GeneralRe: How to get rid of this ERROR Pin
pl_kode28-Apr-08 3:52
pl_kode28-Apr-08 3:52 
GeneralRe: How to get rid of this ERROR Pin
pl_kode28-Apr-08 4:17
pl_kode28-Apr-08 4:17 
QuestionRe: How to get rid of this ERROR Pin
Rajkumar R28-Apr-08 4:46
Rajkumar R28-Apr-08 4:46 
GeneralRe: How to get rid of this ERROR Pin
CPallini28-Apr-08 4:54
mveCPallini28-Apr-08 4:54 
GeneralRe: How to get rid of this ERROR Pin
pl_kode28-Apr-08 17:39
pl_kode28-Apr-08 17:39 
QuestionRe: How to get rid of this ERROR Pin
CPallini28-Apr-08 21:15
mveCPallini28-Apr-08 21:15 
GeneralRe: How to get rid of this ERROR Pin
Maximilien28-Apr-08 4:03
Maximilien28-Apr-08 4:03 
GeneralRe: How to get rid of this ERROR Pin
pl_kode28-Apr-08 4:16
pl_kode28-Apr-08 4:16 
GeneralRe: How to get rid of this ERROR Pin
cagespear28-Apr-08 8:07
cagespear28-Apr-08 8:07 
GeneralRe: How to get rid of this ERROR Pin
pl_kode28-Apr-08 17:35
pl_kode28-Apr-08 17:35 
GeneralRe: How to get rid of this ERROR Pin
Rajkumar R28-Apr-08 19:19
Rajkumar R28-Apr-08 19:19 
Questionhow to get information about plug-n-play devices Pin
vijay.victory28-Apr-08 3:07
vijay.victory28-Apr-08 3:07 
AnswerRe: how to get information about plug-n-play devices Pin
JudyL_MD28-Apr-08 6:48
JudyL_MD28-Apr-08 6:48 
GeneralSet the default export path for Crystal Reports [modified] Pin
AeJai28-Apr-08 2:47
AeJai28-Apr-08 2:47 
GeneralStrange behavior / Click events on disabled button get queued and process later.. Pin
scorpion king28-Apr-08 2:45
scorpion king28-Apr-08 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.