[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: why 0.1+0.2-0.3~=0
- From: Vaughan McAlley <vaughan@...>
- Date: Fri, 16 Mar 2012 20:02:12 +1100
> On Thu, Mar 15, 2012 at 20:16, Roberto Ierusalimschy
> <roberto@inf.puc-rio.br> wrote:
>>> > Is there an easy way to get back the hexa string representation of a
>>> > given number value ?
>>>
>>> print ( string.format("%.13a", given_number) )
>>>
>>> Note: the ".13" format is only necessary on Microsoft compiler, which
>>> by default only displays 5 hexadecimal digits.
>>
>> Which is against the standard:
>>
>> ISO/IEC 9899:1999 (E), §7.19.6.1
>>
>> a, A [...] if the precision is missing and FLT_RADIX is a power of 2,
>> then the precision is sufficient for an exact representation of the
>> value;
>>
>> -- Roberto
>>
I hope Lua and IEEE give 1 + 2 + 3 + ... = -1/12 :-)
- References:
- why 0.1+0.2-0.3~=0, Karol Bielecki
- Re: why 0.1+0.2-0.3~=0, Alexander Gladysh
- Re: why 0.1+0.2-0.3~=0, Dirk Laurie
- Re: why 0.1+0.2-0.3~=0, Ross Bencina
- Re: why 0.1+0.2-0.3~=0, Luiz Henrique de Figueiredo
- Re: why 0.1+0.2-0.3~=0, Roberto Ierusalimschy
- Re: why 0.1+0.2-0.3~=0, Jerome Vuarand
- Re: why 0.1+0.2-0.3~=0, Patrick Rapin
- Re: why 0.1+0.2-0.3~=0, Roberto Ierusalimschy
- Re: why 0.1+0.2-0.3~=0, Rena