RE: Haskell Report (again)
Dale is absolutely right! How has this entirely bogus code survived so long? Here is an (alleged) fix, which works in the tests I've tried. If anyone else can spare a moment to check my code I'd be very grateful. This is definitely going in the Revised H98 report! Thanks Dale. Simon ================ Library Report, Numeric library, Section 4.1, page 13. In the definition of formatRealFloat, in the definition of doFmt, in the FFFixed branch of "case fmt of ...", in the Nothing branch of "case decs of ..." replace the entire branch "Nothing -> ..." with Nothing | e >= 0 -> take e (ds ++ repeat '0') ++ "." ++ mk0 (drop e ds) | otherwise -> "0." ++ replicate (-e) '0' ++ ds =========================== | -----Original Message----- | From: Dylan Thurston [mailto:dpt@math.harvard.edu] | Sent: 17 July 2001 07:33 | To: Simon Peyton-Jones | Cc: haskell@haskell.org | Subject: Re: Haskell Report (again) | | | On Tue, Jul 10, 2001 at 05:50:08AM -0700, Simon Peyton-Jones wrote: | > As ever, the draft is at | > | > http://research.microsoft.com/~simonpj/haskell98-revised | > | > I'm really hoping this is the final version, but experience | suggests | > that whenever I say that someone discovers an entirely new | question! | > So I'm putting it out again for you to pick over. | | I'm astonished no one has noticed this before, but in the | library report for the Numeric library, the definition of | showFFloat is buggy: | | showFFloat Nothing 0.02 "" | | goes into an infinite loop. (There is an auxiliary function | 'f n s ds' which does not consider the case n < 0). | | This suggests that there needs to be a code review of | formatRealFloat, which I have not yet done. | | --Dylan Thurston |
On Fri, Jul 20, 2001 at 04:59:05AM -0700, Simon Peyton-Jones wrote:
Dale is absolutely right! How has this entirely bogus code survived so long?
Err, my name is Dylan...
Here is an (alleged) fix, which works in the tests I've tried. If anyone else can spare a moment to check my code I'd be very grateful.
(a) Where's the definition of mk0? (It was in the text you deleted.) (b) What is the code supposed to do? The code you posted always prints a decimal point; I imagine this is intended? Can this be documented? (c) I don't think the case e=0 is right; you miss the initial "0". (d) "floatToDigits" seems to return an exponent that is off by 1 from what I expected at first. This is reasonable, but since the function is exported, it should be documented. Best, Dylan
================ Library Report, Numeric library, Section 4.1, page 13. In the definition of formatRealFloat, in the definition of doFmt, in the FFFixed branch of "case fmt of ...", in the Nothing branch of "case decs of ..." replace the entire branch "Nothing -> ..." with
Nothing | e >= 0 -> take e (ds ++ repeat '0') ++ "." ++ mk0 (drop e ds) | otherwise -> "0." ++ replicate (-e) '0' ++ ds
===========================
participants (2)
-
Dylan Thurston -
Simon Peyton-Jones