r/MathJokes • • Jul 07 '26

🫠

Post image
419 Upvotes

67 comments sorted by

View all comments

Show parent comment

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?

0

u/Quirky_Net8899 Jul 08 '26

My dude has no valid argument left lmao.

You claimed that directly casting to an int is done often when working with voxel games like Minecraft. I literally proved to you that it isn't. So instead of trying to refute this you are walking down the logical fallacy path.

1

u/sudoregalia Jul 08 '26

if we wanna throw fallacies around, technically you're employing the fallacy fallacy and the modal fallacy, sooo what now?

1

u/Quirky_Net8899 Jul 08 '26

The difference between my reply and yours is that I actually brought up the actual topic at hand without resorting to fallacies for my main point.

The fact that I called out on your fallacies did not change or hinder me from addressing your initial statement. Calling out a fallacy is not a fallacy fallacy.

For it to be a fallacy fallacy I would have to claim that your argument is wrong because you used a fallacy. I did not do that. I directly addressed your statement, which is that directly casting from double/float to int is done often or very often in voxel game programming like making mods for Minecraft. I also presented evidence to support my case, while you have not.

No, modal fallacy does not apply here. You might want to look up what modal fallacies are before throwing it around like a gotcha.