in reply to Floating point (in)accuracy: more "interesting" than expected
I think the descrepencies you are seeing have nothing to do with floating point accuracy, and everything to do with hash seed randomization.
As I understand it, in older versions of perl, the hashing algorithm was (somewhat) deterministic, making it possible to "predict" things -- which is not so good for security. circa perl 5.8.1, the hasing algorithm was changed so as to be non-deterministic. ie: every time you run your app, you get a slightly different hashing seed
Which means: every time you run your app, even on identicle input, hashes you build will be slightly different, and the order the elements come back (from either keys or values) will be different. So the second time you execute your app, and loop over the output of values and do incrimental floating point calculations -- you are doing slightly different calculations the the first time you executed the app.
I can't confirm any of this, because I don't have access more then one version of perl right now, but i believe that if you use "sort values" instead of "values" you'll get a deterministic result on any version of perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Floating point (in)accuracy: more "interesting" than expected
by graff (Chancellor) on Dec 11, 2004 at 20:42 UTC | |
by hossman (Prior) on Dec 11, 2004 at 21:32 UTC |