In article <cu7hml01e9n / enews2.newsguy.com>, Phil Tomson <ptkwt / aracnet.com> wrote: > >I've got some code that does simulated fixed-point math and things like >exp(-x). I find that my simulations work fine on a Windows XP box, >Pentium IV, Ruby 1.8.2. However, when I run the same exact Ruby code on my >Powerbook G4 running Ruby 1.8.1 I get lots of errors from my unit tests. > >I suspect that what I'm doing is really stressing the floating point >operations so it could just be a difference between the G4 and Pentium >FPUs, but I'm also wondering if there were changes between Ruby 1.8.1 and >Ruby 1.8.2 that might account for this (even changes to the way Bignum >works, might account for it). I'll load up Ruby 1.8.2 on the Powerbook >tonight to see if that makes any difference... > > >For the curious, I created a class called FixedPt which allows you >simulate fixed point math (useful for hardware design). So you can do >things like: > >fp = FixedPt.new(Math.exp(-5),18,18) > >Which defines an 18bit register with the binary point at bit 18 and stuffs >the result of Math.exp(-5) into it (shifting the result to the left 18 >times). > >fp.to_f #=> 0.00673675537109375 >fp.raw #=> 1766 >fp.to_i #=> 0 > > a followup.... I loaded up 1.8.2 on my powerbook last night and had the same problem (which doesn't exist on the Pentium IV). I suspect it's a difference in the FPU between the G4 and PIV. I'm doing lots of summations and conversions between floating point and fixed point, so I suspect it's the fault of the G4's FPU..... unless someone else has any other theories. At any rate, it doesn't seem to be some difference in Ruby versions. Phil