I recently defied my supervisor and used Haskell to write my coursework
instead of C. All went well until I needed floating point and
started having odd results. As far as I can tell it isn't
substantially affecting my results but it is rather embarrassing after
slagging off C so much. Here are
Hi,
*Main 0.2 + 0.1
0.30004
Prelude (0.1 :: Float) + (0.2 :: Float)
0.3
Prelude (0.1 :: Double) + (0.2 :: Double)
0.30004
Prelude (0.1 :: Float) + 0.2 == 0.3
True
If you use Float's instead of doubles, it stores less precision, and
so gets it right.
This is more of a haskell-café than a ghc users question,
but I'll put some thoughts here:
On 2006-08-30 at 19:38BST Jamie Brandon wrote:
I recently defied my supervisor and used Haskell to write my coursework
instead of C.
If the object of the course is to teach you (more about) C,
that might
On Wed, Aug 30, 2006 at 07:38:35PM +0100, Jamie Brandon wrote:
I recently defied my supervisor and used Haskell to write my
coursework instead of C. All went well until I needed floating point
and started having odd results. As far as I can tell it isn't
substantially affecting my results but
On Wed, 2006-08-30 at 14:58 -0400, David Roundy wrote:
It's
sad, but we're stuck with it, as I'm not aware of any compiler that is
capable of generating IEEE arithmetic.
Gcc man page:
-ffast-math
Sets -fno-math-errno, -funsafe-math-optimizations, -fno-trap‐
ping-math, -ffinite-math-only,
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
On Wed, 2006-08-30 at 22:29 +0100, Jamie Brandon wrote:
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.
[]
You can always define an infix version of
== (maybe ~=~ or something) that is a bit sloppier
On Aug 30, 2006, at 14:58 , David Roundy wrote:
On Wed, Aug 30, 2006 at 07:38:35PM +0100, Jamie Brandon wrote:
I recently defied my supervisor and used Haskell to write my
coursework instead of C. All went well until I needed floating point
and started having odd results. As far as I can tell
Slightly tongue in cheek, I think the real problem is that your
courses come in the wrong order. No one should use floating point
numbers without first having a course in numerical analysis. :)
-- Lennart
On Aug 30, 2006, at 14:38 , Jamie Brandon wrote:
I recently defied my
On Aug 30, 2006, at 6:04 PM, Lennart Augustsson wrote:
On Aug 30, 2006, at 14:58 , David Roundy wrote:
On Wed, Aug 30, 2006 at 07:38:35PM +0100, Jamie Brandon wrote:
I recently defied my supervisor and used Haskell to write my
coursework instead of C. All went well until I needed floating
10 matches
Mail list logo