Created
July 27, 2025 14:16
-
-
Save tompng/6ada3261f7d43d8a8eb09b2a409b1b33 to your computer and use it in GitHub Desktop.
float num with many zeros: 1.1795176680648731e+39 == 1179517668064873100000000000000008388608.0
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
def euclidsolve(cx, cy, c, small) | |
return euclidsolve(cy, cx, c, small).reverse if cx > cy | |
# cx <= cy | |
# x * cx + y * cy = c + small | |
# p [cx.to_f, cy.to_f, c.to_f, small.to_f] | |
if small >= cy | |
# cx <= cy, c < cy | |
# cx*x + cy*y == c + small | |
# x=0; cy*y == c + small | |
return [0, 1] | |
end | |
x, y = euclidsolve(cx, cy % cx, c % cx, small) | |
# x * cx + y * (cy%cx) == c%cx + small | |
# (x+dx) * cx + (y+dy) * (cy%cx + (cy/cx)*cx) == c%cx + (c/cx)*cx + small | |
# dx * cx + dy + (y+dy) * (cy/cx)*cx == (c/cx)*cx | |
[x + (c/cx) - y * (cy/cx), y] | |
end | |
x,y=euclidsolve(cx=2**622, cy=10**187, c=10**(187-16)/2, small=2**(621-53)) | |
(53..1024).each do |bit| | |
exp10 = (-400..400).bsearch{ | |
2**bit<10**it | |
}-1 | |
x,y=euclidsolve(cx=2**bit, cy=10**exp10, c=10**(exp10-16)/2, small=2**(bit-1-53)) | |
if x.abs.bit_length <= 53 | |
f=(x*2**bit) | |
match = f.to_s[/^\d{14}+0{5,}+[1-9]|^\d{14}9{5,}+[0-8]/] | |
p [match.size, match, f.to_f] if match && match.size > 16 | |
end | |
rescue | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment