Skip to content

Instantly share code, notes, and snippets.

@qmx
Created March 26, 2012 00:58
Show Gist options
  • Save qmx/2201974 to your computer and use it in GitHub Desktop.
Save qmx/2201974 to your computer and use it in GitHub Desktop.

I was trying to help @joshkalderimis b/c an apparent bug running guillotine on jruby

https://github.com/technoweenie/guillotine/blob/master/lib/guillotine.rb#L46-48

The hexdigest to_i(16) was returning a bignum, and packing a bignum on unsigned integers did not looked that cool...

Then I started to dig through MRI's code

https://github.com/ruby/ruby/blob/trunk/pack.c#L240-251

https://github.com/ruby/ruby/blob/trunk/bignum.c#L1185-1204

Am I crazy or MRI is really truncating the numbers? This could potentially give collisions on guillotine...

Is the step 3 (https://github.com/technoweenie/guillotine/blob/master/lib/guillotine.rb#L40) lossy by design?

I hope to be crazy!!

Thoughts?

-- qmx

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