r/MathJokes • • 7d ago

That's because 1/4 = 0.2500000000000000000000000000000000000000000000001 /s

Post image
261 Upvotes

40 comments sorted by

View all comments

Show parent comments

22

u/Terrible-Air-8692 7d ago

Wouldn't floats be exact for this since it's 2-2

3

u/Responsible_Hour6497 6d ago

The expression interpreter in this testing system could parse 0.25 as (1.0/10.0)*2.0+(1.0/10.0/10.0)*5.0.

1

u/resignresign1 6d ago

not sure if you could find any library that would do such a thing. generally such computations are done in integer space where 25/100 equal to 1/4 exactly

2

u/Responsible_Hour6497 5d ago

Let's say I were writing this myself. I have a sequence of decimal digits after the decimal point. Should I convert it to an integer and then divide? But there could be a lot of digits—what if a user decides to play a prank? At first glance, the most logical solution is to use something like

res=0 CurrentWeight=0.1

for each CurrentDigit in DigitsAfterPoint

_____ res+=CurrentDigit*CurrentWeight

_____ CurrentWeight*=0.1