|
-
Dec 14th, 2007, 03:27 PM
#1
-
Dec 14th, 2007, 03:42 PM
#2
Frenzied Member
Re: 20.0 - 12.0 = 7.999999... ???
I had this problem in a game I wrote. It's because they are floats and something about accuracy loss or something like that..
Just use the overloaded version of the ToString method to format it. Or some other format method.
-
Dec 14th, 2007, 08:00 PM
#3
Re: 20.0 - 12.0 = 7.999999... ???
This is one of the drawbacks of using floating-point numbers. If all values are whole numbers then you should use Point rather than PointF values. Otherwise you could try rounding results to a specific number of significant digits if all your original values are also to that many significant digits. If there's division involved anywhere it starts to get more complex though.
-
Dec 15th, 2007, 10:50 AM
#4
Re: 20.0 - 12.0 = 7.999999... ???
Thanks for the reply.
I need the values to be single, so there no change needed.
I found this one only will testing and got a bit worried.
Looks like I didn't do anything wrong, so I'm fine.
Thanks
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|