[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: infinities reformulated

This page is part of the web mail archives of SRFI 70 from before July 7th, 2015. The new archives for SRFI 70 contain all messages, not just those from before July 7th, 2015.



Aubrey Jaffer <agj@xxxxxxxxxxxx> writes:

> To first order:
>
>   (define (precision-of x) (string-length (number->string x)))
>
> R5RS requires all numbers to have external representations; and it
> specifies the allowed formats.

What?  number->string does not specify the allowed formats for exact
numbers, only for inexact (and only for some inexact numbers at that).
This isn't an accident; it was done specifically for just this reason,
to allow for different representations.  See the Rationale:

"The unspecified case allows for infinities, NaNs, and non-flonum
representations."

So if X is an exact version of sqrt 2, it's perfectly fine for
number->string to return anything that string->number can understand.

Thomas