Stefan Kahrs writes:

> I just wanted to draw attention to the fact
> that there is an ANSI group working on the standardisation of
> "Language independent arithmetic".  The draft is undergoing public
> review now.  Scanning casually through the pages,
> my first impression is that there might be some differences to the
> Haskell definition and it would be probably worthwhile to add our
> 0.02$ to the discussion.

A word of explanation about LIA - it is intended to give a specification
of computer arithmetic sufficiently accurate for things like error bound
analysis, but sufficiently flexible that different arithmetic implementations
can conform. It does this essentially by parameterising floating point
implementations by their radix, number of digits precision and exponent
range. Most known implementations of arithmetic conform, including IEEE.

LIA also specifies certain functionality that an implementation should
provide. This means the usual arithmetic operations; a way of finding
minimum/maximum floating point and integer numbers (yes, it does allow
unbounded integers); and ways of disassembling and reassembling
floating point numbers.

I have studied the current draft of LIA (NPL was responsible for at least
part of it) to see how well Haskell fits. I am sure that everyone will be
delighted to know that it conforms far better than almost any other
language I am aware of. There are two main points of difference:

1. LIA requires a function 'denorm' for floating point types. This gives
   True or False as the type does or does not contain denormalised
   values. This is an important function for numerical analysts, which
   cannot be written legally in Haskell and, I believe, should be added
   to the language. (By "cannot be written legally" I mean that you can
   write a function that gives the right result on existing implementations
   but it relies on implementers giving zero on underflow rather than
   raising an exception.)

2. Haskell's behaviour on overflow/underflow is undefined. LIA requires
   an exception to be raised in these circumstances. Existing Haskells
   vary in their conformance - I suspect they do whatever the arithmetic
   of the underlying system does. I personally believe that LIA is right
   about this - I would rather my program fell over and died than did
   wraparound arithmetic on Ints without telling me. However, feelings
   run high on this, so I am not complaining too loudly.

I have a not-quite-finished report on LIA and Haskell, which includes
a model implementation in Haskell of the bits of LIA which
are not built-in Haskell functions. Anyone who is interested should email
me for a copy.

Nick North                           [EMAIL PROTECTED]
National Physical Laboratory, UK

Reply via email to