Created
April 16, 2016 09:42
-
-
Save mamantoha/80083bcfc606dbf452ecb33603e73e0d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fi = Float::INFINITY | |
p = 1 | |
p *= 2 while 2**p < fi | |
a = p/2 | |
b = p | |
m = a/2 | |
p = a + m | |
until (2**(p-1) != fi) && (2**p == fi) | |
m.zero? ? m = 1 : m = m/2 | |
2**p == fi ? p -= m : p += m | |
end | |
print "Result: " | |
puts p - 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment