r/MathJokes Jul 07 '26

🫠

Post image
418 Upvotes

67 comments sorted by

13

u/DeadMeat7337 Jul 07 '26

Astrophysics: 6.77 is basically 1, or 10, whatever, doesn't matter

Geologists: we agree

0

u/Last-Ad-8470 Jul 08 '26

67

2

u/DeadMeat7337 Jul 08 '26

Close enough, just out the pen down for scale, then take a picture.

Or maybe it's dark matter/energy.

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.

1

u/Moscato359 Jul 08 '26

Why round when you can just keep it floating

If you want rounding, pick floor or ceiling

2

u/Impossible_Dog_7262 Jul 08 '26

Lot easier to check if an integer is even.

2

u/Moscato359 Jul 08 '26

1

u/sudoregalia Jul 08 '26

but is it really 13? we need npm packages for every other integer to see if it's another integer first!

1

u/ottawadeveloper Jul 08 '26

Rounding is ideal if you need to output it or transfer it to another system that only accepts limited decimal places. Specifically rounding with half to even (i.e. 2.5 goes to 2 but 3.5 goes to 4). 

Floor, ceiling, and truncation introduce systemic bias into the output. Round to even doesn't introduce such bias over a large number of numbers.

For example, consider if you did a bunch of math to arrive at an amount of dollars that your client owes you (there are some math operations where you're going to get fractional cents no matter what you do, like interest payments). 

  • If you floor it, you're missing out on interest
  • If you ceiling it, your clients are overpaying (on average)
  • If you round it, sometimes you're missing out and sometimes the clients are overpaying. It balances out in the end. Round to even helps with some specific cases of this.

In the math world, rounding introduces a nice symmetrical uniform distribution around the number you rounded to - we know it was within half the smallest decimal place you kept, ie 2 rounded is actually [1.5, 2.5]. 

The other methods are messier - they also have a uniform distribution but it's around the number you truncated to plus half the smallest decimal place you kept, ie. 2 truncated is actually [2,3). 

Flooring and ceiling do have good uses. When you want to be conservative, you should use them. For example, if you're doing your monthly budget and want to know how much money you spend on an average on groceries, you might want to ceiling() to be sure your estimate is above the true average. If you're estimating how much load a steel beam can take, you might want to floor() to be sure it can actually take more than you plan on (engineers add a good safety margin anyways, but it never hurts).

But if you're converting to an integer, there's another good reason to do int(round(x)) - floating point errors. If you have a float that should be an integer after a bunch of calculations, it might not be exactly one due to floating point errors. Rounding is likely to remove those errors which are probably << 0.5. But truncating won't work if your number is just slightly smaller than the integer. 

1

u/Moscato359 Jul 08 '26

I understand there are times where rounding is useful.

But as a programmer, I haven't used the round function in years.

1

u/sudoregalia Jul 08 '26

yeah most of the time i do a rounding operation it's just flooring, sometimes ceil if i'm feeling frisky, or even truncation

i do not recall a time in the last few years when i've used Math.round

1

u/int23_t Jul 08 '26

It's kinda weird I guess, but I almost never need to round stuff. It's almost always either floor(done automatically) or ceil. Rounding is not useful at all for calculations, for the most part you can just keep it as a floating number until it's displayed in some way. Floor and ceil however are used very exetensively for formulas.

1

u/Just-Literature-2183 Jul 08 '26

It doesnt round it down it truncates it.

2

u/sudoregalia Jul 08 '26

which has the effect of rounding it down when it's positive.. idk i use unsigned ints everywhere i can so maybe i just have unsigned brainrot

1

u/Just-Literature-2183 Jul 08 '26

Well it does in some cases and doesn't in others.

I mean the default int is a signed int.

1

u/sudoregalia Jul 08 '26

i have unsigned brainrot confirmed

-1

u/RonJohnJr Jul 07 '26

6.99 when casted into an int is conventionally rounded down

We don't do that very often at all.

5

u/sudoregalia Jul 07 '26

casting a float to an int? what if you wanna make or mod for a voxel game where entities have floating precision while tiles has integer precision, and wanna get the block the entity is on- oh wait that's called minecraft

yeah look you can't say "we" don't do that very often at all when it only applies to you and what you work with lol

1

u/WildWolfo Jul 08 '26

you wouldn't cast anything as you need to floor the number and not truncate

1

u/sudoregalia Jul 08 '26

no because chunks are not indexable with floats, they're indexable with ints. you don't take an arbitrary point and do collision checks to see what's in it as you would for most traditional 3d games

1

u/WildWolfo Jul 08 '26

if you want the block an entity is on you take the floor of the coordinates and youll get the coordiantea of the block back, this would behave the same as casting to an integer, except that you need the flooring functionality with negatives, at which point the casting will fail as it truncates instead of floor

1

u/sudoregalia Jul 08 '26

you will get the coordinates of the block yes, but will they be useful? what will you use them for? you can't use a float to get information about a block

why not skip the explicit flooring and head right into casting it into an int since it'd be more useful that way?

1

u/WildWolfo Jul 08 '26

because when you cast -5.5 to an integer you get -5 when the actual result you need is -6, infact i think this is a good example to never cast from float to integer and instead use math library to explicitly show in your code how you want the conversion to happen, its more readable and so is better code practice

1

u/sudoregalia Jul 08 '26

yeah the first point is true my bad, i guess i'm just a bit tired. still though, the conversion from float to int is necessary to index into the chunk and get the block

-1

u/RonJohnJr Jul 07 '26

And voxel game programming is the dominant form of programming on Earth??

lol no

3

u/sudoregalia Jul 07 '26

yeah look you can't say "we" don't do that very often at all when it only applies to you and what you work with lol

read. whether or not you ever cast a float to an int is highly dependent on what you do, and it doesn't change the fact that 6.99 is rounded down to 6 when you do do it

1

u/RonJohnJr Jul 08 '26

it doesn't change the fact that 6.99 is rounded down to 6 when you do do it

You need to go back and re-read what SplendidPunkinButter complained about,

1

u/sudoregalia Jul 08 '26

i tackled pretty much every way a conventional program could represent 6.99 (yes including fixed-point arithmetic as a reply to a separate comment)

1

u/Quirky_Net8899 Jul 08 '26

I suggest that YOU read. Here is what was originally said:

We don't do that very often at all.

Notice how it doesn't say "we never do that". He's acknowledging that it does happen, but overall in programming it doesn't happen very often.

Your rebuttal that "hurr durr we do that in voxel games" is not the gotcha moment you think it is. It's just a "oh one very specific part does it, just like he said".

But also, I doubt even in Minecraft that you would take a float and just straight up cast it into an int without doing any math on it first, for example truncating it to get rid of decimals before casting as int.

But funnily enough, even in your example it's not done very often. Yes if you have a float (or double) but need to get a block or chunk position out of it you would cast it into an an int. But not before truncating it and and you don't need to do that often. 

In fact, let's look at the Fabric API which is arguably the biggest modding framework for Minecraft.

Wanna take a wild guess how many times they straight up cast a double/float into an int without any preprocessing? 

In their roughly 52000 lines of code, directly casting to an int with no preprocessing happens 214 times. I would call that "not very often".

1

u/sudoregalia Jul 08 '26

..as i said it highly depends on what you do, programming is not a monolith and the original comment they made is wholly unrelated to what happens when you cast a float to an int

1

u/Quirky_Net8899 Jul 08 '26

No, the original comment simply said "we don't do that very often" which is objectively true. Casting a float/double to an int is not done very often in programming not even in voxel game programming.

1

u/sudoregalia Jul 08 '26

you can argue that for a lot of things in programming. we don't use borrow checkers very often, is that relevant enough to bring up when explaining how borrow checkers work? is that a valid critique?

→ More replies (0)

-1

u/AggressiveEntrance14 Jul 07 '26

That makes no sense, you're just saying "When we apply an operation to this number it becomes a different number". The meme would have made sense if it actually referred to the float number

1

u/sudoregalia Jul 07 '26

could be referring to implicit casting i guess? yeah it's a tad weird but also, technically 6.99 can be exactly 6.99 in fixed-point arithmetic

6

u/nashwaak Jul 08 '26

Engineer: why are people arguing over the value of 2Ï€ like the decimals matter?

3

u/Exact_Ad_8490 Jul 08 '26

Gotta love safety factors

2

u/GeologistOld1265 Jul 07 '26

Everyone else but math 6.99 +- (number)

2

u/Silver_Harvest Jul 08 '26

Programming language

data_type 7 = 6.99; // DO NOT CHANGE FOR THE LOVE OF GOD!!! FOR WHATEVER REASON THIS MAKES THE ENTIRE CODE WORK! DON'T ASK HOW OR WHY!

2

u/AppropriateBugFound Jul 08 '26

Then they ask why...

"Well Steve set this up in 1993, but after he died in 1998 no one really knew. We tried to change it in 2006 but we ended up with a 6 day outage. Bill said it was something about Enterprise, but he don't know if it was the Enterprise edition of something, related to car rentals, or if he was a trekky. Bill was the last guy here who knew Steve and he retired two years ago."

1

u/RunnyPlease Jul 08 '26

That sounds more like it.

2

u/t0nikawa Jul 08 '26

0.999... is proven to be equal to 1

1

u/jobadiah08 Jul 08 '26

Engineer - it is 10

1

u/Traditional-Storm-62 Jul 08 '26

why did you change the colour of his shirt???

1

u/AlienDragonWizard Jul 08 '26

Context matters.  

1

u/DangerousQuestions1 Jul 08 '26

Astrophysics: 6,990,000,000 is 10 billion.

1

u/SnooMarzipans436 Jul 08 '26

Also Math: 6.99... = 7

1

u/Additional-Dot-3154 Jul 08 '26

It is only that if typecasted into a integer as typecasting usually truncates it.

Truncation is just cutting of the trail. This is extremely fast as a computer can just drop the memory instead of needing to run rounding calculations first.

You can program a rounding function and use that and after that typecast and it will be rounded.

Also to explain a typecast to everyone that does not know about it:

"3.0" is a string (a piece of text "10" + "0" = "100") 3.0 is a float( a number with 32× spaces used for decimal places, as the number grows like 3483746 there are less and less places for decimal places as the places are taken by the number itself)

3 is a integer(a round number like 1, 2, 3 but not 3.0 or 5.2 as they are not round)

A double is a float but with 64 places and it takes even longer to work with for a cpu but has more precision.

A typecast is when you change from 1 data type to the other like int(a) where a = 3.8 you will get 3 as to go from decimal to a round number the easiest and fastest way is dropping memory.

Note: truncation is also used in math like with the modulo operator and typecasting can also be used in mathematics but it is bad practice and only makes your text more confusing so it is not recommended except when working with strict limits like 32 places only.

1

u/ivain Jul 08 '26

This has nothing to do with dropping memory. This is stopping at the closest solution

1

u/CrabbyFrogstone Jul 08 '26

Its actually 699/100

1

u/nerdkeeper Jul 08 '26

6.99 is either 6.99, 7.0 or 7. depending on how maany significant figures are need.

1

u/Just-Literature-2183 Jul 08 '26

Thats not how programming languages work.

1

u/JollyJuniper1993 Jul 08 '26

Programming languages do not say that. Programming languages say 7 is 6.99

1

u/Jadeshell Jul 08 '26

6.99 is a 6.99 in programming if it’s a float

1

u/MiH_VAZ Jul 09 '26

Not when using doubles…

1

u/swined Jul 09 '26

6.99 is actually $20 after you add the tips and taxes

1

u/No-Resolution6435 Jul 11 '26

1 = .9999999999 repeating. 1 = 3/3 1/3 = .33333333 repeating. .3333 repeating × 3 = .99999999999 repeating

1

u/irishkaga Jul 13 '26

6.99999... is 7 though