Re: Floating point problems

2006-09-05 Thread David Roundy
On Fri, Sep 01, 2006 at 10:11:30AM +0100, Simon Marlow wrote: > Nowadays -mfpmath=sse is better than -ffloat-store, because SSE2 has single > and double-precision floating point arithmetic. I get pretty reproducible > arithmetic on x86_64 this way, where SSE2 is the default. Thanks for the tip!

Re: Floating point problems

2006-09-01 Thread Simon Marlow
David Roundy wrote: On Thu, Aug 31, 2006 at 07:44:33AM +0200, Florian Weimer wrote: * > 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 You

Re: Floating point problems

2006-08-31 Thread David Roundy
On Wed, Aug 30, 2006 at 06:04:47PM -0400, Lennart Augustsson wrote: > On Aug 30, 2006, at 14:58 , David Roundy wrote: > >The trouble here is that ghci is printing more digits than it > >really ought to be printing. > > No, I don't think it is. Ghci is printing the number that is closest > of al

Re: Floating point problems

2006-08-31 Thread David Roundy
On Thu, Aug 31, 2006 at 07:44:33AM +0200, Florian Weimer wrote: > * > 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 > > Yo

Re: Floating point problems

2006-08-31 Thread Florian Weimer
* > 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 You quoted the wrong paragraph. Here's the right one: `-ffloat-store' Do n

Re: Floating point problems

2006-08-31 Thread Florian Weimer
* David Roundy: > definition of the variable and the comparison, this check may be > failed. The reason is that intermediate results are commonly stored "commonly" = "on legacy i386 platforms" > at higher than double precision, leading to non-IEEE arithmetic. AFAIK, GCC's behavior is not in it

Re: Floating point problems

2006-08-30 Thread Lennart Augustsson
On Aug 30, 2006, at 20:44 , Jan-Willem Maessen wrote: 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 coursew

Re: Floating point problems

2006-08-30 Thread Jan-Willem Maessen
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 p

Re: Floating point problems

2006-08-30 Thread Lennart Augustsson
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 supervi

Re: Floating point problems

2006-08-30 Thread Lennart Augustsson
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

Re: Floating point problems

2006-08-30 Thread skaller
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

Re: Floating point problems

2006-08-30 Thread Jamie Brandon
>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

Re: Floating point problems

2006-08-30 Thread skaller
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

Re: Floating point problems

2006-08-30 Thread David Roundy
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 b

Re: Floating point problems

2006-08-30 Thread Jon Fairbairn
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 migh

Re: Floating point problems

2006-08-30 Thread Neil Mitchell
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.

Floating point problems

2006-08-30 Thread Jamie Brandon
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 som