[C++-sig] About floating point numbers...

sonnur ayverdi ayverdisonnur at hotmail.com
Fri Aug 15 14:19:30 CEST 2003


Hello,

I took your email address from an article about floating point numbers.I'd 
like to ask you a question about this subject.I hope you help me.

I use C++Builder .I write the code below that has the problem and try to 
explain the problem:

int deg;
double mul;
Ansistring ans;

if ans = 999.9 and mul = 10.0
atof(ans.c_str())*mul = 9999
deg = (int)(atof(ans.c_str())*mul) deg is found 9999  (There is no problem)

But when I try to run this program in Windows98
if ans = 999.9 and mul = 10.0
atof(ans.c_str())*mul = 9999
deg = (int)(atof(ans.c_str())*mul) deg is found 9998  (******THE 
PROBLEM******)

It is also same if the number is 999.8->9997, 999.4->9993, 999.3->2.But this 
bug occurs only in Windows 98,there is no problem with this number in 
Windows95.
I hope you will help me with this subject.
Thanks a lot
Sonnur

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963





More information about the Cplusplus-sig mailing list