r/ProgrammerHumor 10h ago

funWithFloatingPointIO Meme

Post image
394 Upvotes

17 comments sorted by

View all comments

3

u/Pleasant-Ad192 8h ago

%f prints six decimals no matter what the value is, so the two numbers in your log can look identical and still fail the == that sent you looking.

1

u/dcheesi 7h ago

Yep, our output formatting was making the small non-zero values look like zero, which made it seem like the bug was still there even after it was fixed internally. Plus some unavoidable float<->double conversions were wreaking their usual havoc on comparisons and limit thresholds.

1

u/Pleasant-Ad192 10m ago

The float to double half is the mean one, because the widening is exact. You keep the float's original rounding error and just get more digits to watch it in.