[Haskell-cafe] Desired behaviour of rounding etc.

Simon Marlow marlowsd at gmail.com
Wed Oct 13 04:50:50 EDT 2010

On 12/10/2010 15:17, Daniel Fischer wrote:
> On Tuesday 12 October 2010 11:18:39, Simon Marlow wrote:
>> On 09/10/2010 10:07, Daniel Fischer wrote:
>>> On Saturday 09 October 2010 06:34:32, Lennart Augustsson wrote:
>>>> That code is incorrect.  You can't assume that the base for floating
>>>> point numbers is 2, that's something you have to check.
>>>> (POWER6 and z9 has hardware support for base 10 floating point.)
>>> -- We assume that FLT_RADIX is 2 so that we can use more efficient
>>> code #if FLT_RADIX != 2
>>> #error FLT_RADIX must be 2
>>> #endif
>> Making the assumption is fine (as we do in the code above), but the
>> important thing is to make the build fail in a very noisy way if the
>> assumption turns out to be wrong (as above).
>> Cheers,
>>          Simon
> Are there any other places where FLT_RADIX == 2 is assumed?
> (grepping the .hs, .lhs and .h files in the source tree for FLT_RADIX
> revealed nothing else.)
> If that's the only place where e.g. base 10 floating point would fail, we
> should make it work for that too.
> If on the other hand base 2 is assumed in other places, for primops,
> whatever, and that assumption is not going to be changed, I'd prefer not to
> litter the source with dead code.

I think the code in rts/StgPrimFloat.c assumes a lot about floating 
point representations.


More information about the Libraries mailing list