Jump to content
• Advertisement

#### Archived

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

# help float number

This topic is 5311 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

example: m_fX = 0.2f; m_fY = 0.2f; m_fDir = 0.0f; m_esStatus = esIdle; m_fMoveStep = 0.05f; m_fX = (0.20000000) m_fmoveStep = (0.050000001) how to solve this problem?

#### Share this post

##### Share on other sites
Advertisement
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

##### 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

##### 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

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
13
4. 4
5. 5
• Advertisement

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633697
• Total Posts
3013408
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!