Haskell Report (again)
Dylan Thurston
dpt@math.harvard.edu
Fri, 20 Jul 2001 12:33:05 -0400
On Fri, Jul 20, 2001 at 08:35:13AM -0700, Simon Peyton-Jones wrote:
> | (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?
> Sigh. The numeric library is entirely inadequately documented.
> I suppose that now you have forced me to face up to this fact I shall
> have to write some (brief) documentation for at least the exported
> functions.
I could do it, if you prefer.
> | (c) I don't think the case e=0 is right; you miss the initial "0".
> True. The e>=0 should be e>0, I think.
Yes, that should fix it.
> | (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.
>
> Here's a comment I've just deduced and typed in for floatToDigits.
> Does it meet the need?
>
> -- floatToDigits takes a base and a non-negative RealFloat number,
> -- and returns a list of digits and an exponent.
> -- In particular, if x>=0, and
> -- floatToDigits base x = ([d1,d2,...,dn], e)
> -- then
> -- (a) n >= 1
> -- (b) x = 0.d1d2...dn * (base**e)
> -- (c) 0 <= di <= base-1
Looks great!
--Dylan