On Thu, Jul 28, 2011 at 4:54 AM, Igor Stasenko <siguctua@gmail.com> wrote:
Float numbers are inexact and always been.

Maybe you meant that they are more inexact than you expected? :)

FloatArray stores floats using 32-bit floating point precision format.
While Float(s) using 64 bits.
No surprise that values stored in FloatArray are less precise.


Ahhhhhhhhhhh! you are right... I was storing 64 bits:

serialize: aFloat on: aWriteStream
��� aWriteStream
��� ��� nextNumber: 4 put: (aFloat at: 1);
��� ��� nextNumber: 4 put: (aFloat at: 2).

materializeFrom: aReadStream
��� ^ (Float new: 2)
��� ��� at: 1 put: (aReadStream nextNumber: 4);
��� ��� at: 2 put: (aReadStream nextNumber: 4);
��� ��� yourself.

that's why I see a difference!
thanks!!!


On 28 July 2011 08:34, Martin Dias <tinchodias@gmail.com> wrote:
> If forgot to specify that I run this on Pharo 1.3 build #226 in Windows with
> :
>
> Smalltalk vmVersion ----> 'Croquet Closure Cog VM [CoInterpreter
> VMMaker.oscog-eem.56]'
>
> Martin
>
> On Thu, Jul 28, 2011 at 3:30 AM, Martin Dias <tinchodias@gmail.com> wrote:
>>
>> Hi
>>
>> I found that FloatArray>>at:put: is inaccurate:
>>
>> | floats |
>> floats := FloatArray new: 1.
>> floats at: 1 put: 11.22321.
>> floats at: 1 " ------------> 11.223210334777832 "
>>
>>
>> Do you know this issue?
>>
>>
>> This is the implementation of at:put::
>>
>> at: index put: value
>> ��� <primitive: 'primitiveAtPut' module: 'FloatArrayPlugin'>
>> ��� value isFloat
>> ��� ��� ifTrue:[self basicAt: index put: value asIEEE32BitWord]
>> ��� ��� ifFalse:[self at: index put: value asFloat].
>> ��� ^value
>>
>> Thanks in advance
>> Martin
>
>



--
Best regards,
Igor Stasenko AKA sig.