[Haskell-cafe] Re: floating point operations and representation
wnoise at ofb.net
Mon Mar 17 14:51:06 EDT 2008
On 2008-03-17, John Meacham <john at repetae.net> wrote:
> On Mon, Mar 17, 2008 at 12:59:09PM -0400, David Roundy wrote:
>> foreign import ccall unsafe "math.h log10" log10 :: Double -> Double
>> since in ghc CDouble and Double are identical.
>> It's a bit sloppier, but shouldn't cause any trouble. And I've no
>> idea how realToFrac is implemented, but would worry about it behaving
>> oddly... for instance when given NaNs.
> Yes. 'realToFrac' is inherently pretty broken and should be avoided
> whenever possible. It is not all all obvious to me what the correct
> primitive should be.. but we really should do something better for
> haskell'. relying on RULES firing as ghc currently does doesn't seem
> hmm.. maybe a 'FloatMax' type and have 'fromFloatMax' and 'toFloatMax'
> in 'Fractional' and 'Real' respectively? hmm.. hc has 'fromDouble' and
> 'toDouble' there, but jhc also supports a 'Float128' type (when the
> underlying hardware does). so this still isn't quite right.
Well, the whole numeric hierarchy needs to be redone to support proper
mathematical structures like groups, rings, and fields. Once that's
done, this might end up being clarified a bit.
More information about the Haskell-Cafe