On Sun, Sep 7, 2008 at 10:10 PM, Waldek Hebisch wrote:
>
> Bill Page wrote:
>>
>> On Fri, Sep 5, 2008 at 11:58 PM, Waldek Hebisch wrote:
>>
>> > But printing a float and reading it back is likely to mangle the value.
>> >
>>
>> Printing is not important but representing an object as a string is
>> important. Currently both
>>
>>    float(156649750673941512323,-66,2)
>>
>> and
>>
>>    2.123
>>
>> produce the same result when input to the interpreter:
>>
>> (1) -> test(float(156649750673941512323,-66,2)=2.123)
>>
>>    (1)  true
>>                                                          Type: Boolean
>>
>> Can you give an example when this might not be the case?
>>
>
> Just increase precision.

Yes I agree that if one increases the precision, then the internal
representation will change and 'float(156649750673941512323,-66,2)'
will only equal 2.123 in the original precision.

> Internally number are stored with higher precision than specified,

?? If I specify

  precision(68)$Float

it is my understanding that the precision is exactly 68 bits (the
default base is 2). No?

Perhaps you are referring to this comment in the documentation
'float.spad.pamphlet':

++ ...  Second, there is a further loss of accuracy during
++ conversion to decimal for output.  To compensate for this, if d
++ digits of precision are specified, \spad{1 + ceiling(log2 d)} bits
++ are used. Two numbers that are displayed identically may
++ therefore be not equal.

Note: There is a typo here. It should actually read:

++ digits of precision are specified, \spad{1 + ceiling(log2(10^d))} bits

As far as I understand it, this is just to make value specified in
'digits()' look right when a value is printed in decimal notation.

> so probably if you fix precision any value given up to this precision
> after read will give you equal output.  But I belive that numbers coming
> from calculations will change after a round trip (with small, but
> non-negligable probability).
>

My point was just that 'float(156649750673941512323,-66,2)' represents
*exactly* the internal representation of '2.123' in a given precision
(specifically the default precision of 68). I think we agree about
that.

Regards,
Bill Page.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to