[Gambas-user] Precision immediately lost when assigning value to type Single structure property

Kevin Fishburne kevinfishburne at ...1887...
Sun Apr 13 03:45:25 CEST 2014


On 04/10/2014 10:50 AM, Jussi Lahtinen wrote:
> That is completely expected just try:
> Print csingle(180.2)
> 180,1999969
>
> You cannot express 180.2 precisely with 32 bits.
> Even with 64 bits it's something like: 180.199999999999988631 ...
>

Thanks everyone. I knew floating point variables worked differently than 
integer types but didn't realize the extent of the limitations of their 
precision. I was using the value after the decimal as a flag, or a way 
to store two numbers in one. I've worked around the issue by rounding it.

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271





More information about the User mailing list