Archived

This topic is now archived and is closed to further replies.

help float number

This topic is 4944 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It is in the nature of floating-point numbers that they are not exact. There's no way around this; deal with the slight deviations, or use integer types if you need absolute accuracy.

Edit: ... Or fixed-point numbers, or large precision numbers such as the GNU MP library, but not floating-point.

[edited by - Miserable on May 29, 2004 3:47:29 AM]

Share this post


Link to post
Share on other sites
Depending on what you consider the problem:

1. Display less digits -- the formatting code will round appropriately.

2. Floating point numbers are almost always off by a tiny bit. They sacrifice precision in order to extend their range. That cannot be fixed -- that''s the way they work.


John Bolton
Page 44 Studios
Current project: NHL Faceoff 2005 PS2

Share this post


Link to post
Share on other sites
example:

float a = 0.05f;
float b = 0.1f;


void func()
{
b=b+a;
}

this func() be called by anything no-limit times;

the ''b'' is error.

hmm~~!!!!

it''s is not exact also accept.
but every called ADD 0.0000000001f,
i can''t accept autoadd a ''0.000000000001f''

Share this post


Link to post
Share on other sites