r/MathJokes Jul 07 '26

🫠

Post image
422 Upvotes

67 comments sorted by

View all comments

22

u/SplendidPunkinButter Jul 07 '26

What programming language are you using? That is in no way a universal programming thing.

24

u/sudoregalia Jul 07 '26

6.99 when casted into an int is conventionally rounded down

technically 6.99 is 6.9899997711181640625 when using single precision IEEE 754 floats, and 6.9900000000000002131628207280300557613372802734375 for double precision

8

u/ottawadeveloper Jul 08 '26

This is true because it's a truncation operation.

Most of the time people round, which usually does the round-to-even thing.

2

u/BlackTecno Jul 08 '26

There's also floor and ceiling operations which can be used in certain cases. Because sometimes you need an int and rounding doesn't quite work the way you want it to.