[Haskell-cafe] Re: pi
Dan Weston
westondan at imageworks.com
Wed Oct 10 21:00:01 EDT 2007
Dan Weston wrote:
> David Benbennick wrote:
>> On 10/10/07, Dan Weston <westondan at imageworks.com> wrote:
>>> Actually, it is a constant: piDecimalExpansion :: String.
>>
>> Where is this constant defined?
>>
>>> A translation from piDecimalExpansion :: String to pi :: Floating a => a
>>> is already well defined via read :: Read a => String -> a
>>>
>>> Any definition of pi in the Floating class that differs from (read
>>> piDecimalExpansion) is erroneous. I propose the above as the default
>>> definition of pi.
>>
>> piDecimalExpansion, if defined, would be an infinite length string.
>
> It would need to be added. The fact that it has infinite length is no
> problem. It is countable infinite, and algorithms exist to compute this
> lazily.
>
>> The expression
>>
>> read $ "0." ++ repeat '1' :: Double
>>
>> is Bottom. So even if you had piDecimalExpansion, it isn't clear how
>> to use that to define pi.
>
> Ouch. Why is that bottom? Any finite dense numeric type can depend on
> only a finite number of digits.
>
Duh. I forgot about the possibility of scientific notation. Curse
whoever invented that with not putting the exponent before the mantissa!
I propose that henceforth 1.5e-10 be written -10e1.5 (no need to change
the letter, it should cause no confusion), and that read should read
greedily only until an 'e' appears, then lazily afterward.
More information about the Haskell-Cafe
mailing list