Skip to content

Instantly share code, notes, and snippets.

@prakashmurthy
Created October 23, 2010 14:22
Show Gist options
  • Save prakashmurthy/642266 to your computer and use it in GitHub Desktop.
Save prakashmurthy/642266 to your computer and use it in GitHub Desktop.
Why are these two different? The numbers are the same; just re-arranged.
ruby-1.9.2-rc1 > 707106783028.0 * 1 / 1000000002604.0 * 707106783027.0 / 1000000002603.0
=> 0.49999999999999994
ruby-1.9.2-rc1 > 1 / 1000000002604.0 * 707106783027.0 / 1000000002603.0 * 707106783028.0
=> 0.5
@hkoren
Copy link

hkoren commented Oct 25, 2010

On ruby 1.8.5 (2006-08-25) [x86_64-linux] they were the same for me.

irb(main):002:0> 707106783028.0 * 1 / 1000000002604.0 * 707106783027.0 / 1000000002603.0
=> 0.5
irb(main):003:0> 1 / 1000000002604.0 * 707106783027.0 / 1000000002603.0 * 707106783028.0
=> 0.5

You got me to install ruby, congrats. I guess this version installed with my centos linux is much older than yours though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment