Floating point problems

Jamie Brandon jcb73 at cam.ac.uk
Wed Aug 30 17:29:47 EDT 2006


>If the object of the course is to teach you (more about) C,
>that might not go down too well :-)

Its on computer aided research in maths. The choice of language is ours
but the staff refuse to help with any project not written in C. I'm not
sure what we're supposed to be learning but Haskell has seemed far more
suitable than C for all the work I've done so far - I can't imagine
doing the questions on set theory in C.

>You can always define an infix version of
>== (maybe ~=~ or something) that is a bit sloppier in its comparisons,
>of course.

I think that may be the best solution in the short term. I'll look in
Data.Ratio too, though it's not too useful here as I'm doing numerical
integration. Most of the time the functions passed in will have
exponentials, which means I'll always end up using floating point.

>Like the other respondents said, floating point is nasty, best avoided
>when possible, and used with caution plus the advice of numerical
>experts when unavoidable.

I agree entirely. Unfortunately I'm supposed to be an expert.

Thanks for your help.

Jamie





More information about the Glasgow-haskell-users mailing list