Raised This Month: $ Target: $400
 0% 

float 1.3 + 0.1 = 1.399999


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 01-11-2015 , 22:28   Re: float 1.3 + 0.1 = 1.399999
Reply With Quote #1

Floats are not precise enough and both 1.3 and 0.1 can not be accurately represented. By default the AMXX %f formatting will not round this small error away and will thus result in a 1.39999 being output (which is technically correct).

Your floatadd workaround does nothing, it is the %.1f formatting that "fixes" the issue. You can easily verify this using a small C program and printing the same numbers with something like %.12f so the numbers don't get rounded by the library.
__________________
In Flames we trust!

Last edited by Nextra; 01-11-2015 at 22:28.
Nextra is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode