What does 100 - (-math.huge) equal?

You’d think the answer would be simple, but it isn’t. Bonus points if you can explain why it equals that.

1 Like

Is it equal to math.huge or does it overflow into -math.huge?

1 Like

my guess would be that it equals to -inf

1 Like

Well, math.huge is essentially lua’s “infinity”.

So no matter what numerical operation you do, it will always be negative infinity. Because you can’t go above/below negative/positive infinity right?

1 Like

nope, if you print -math.huge it will print -inf and vice-versa

so, 100 - (-math.huge), or simplified: 100 + math.huge is inf

image

image

2 Likes

I’m assuming this is because the math library in luau isn’t based on true math. Sort of like how -0 and 0 are mathematically the same but in luau they’re actually two different numbers.

You are correct! In Luau, or robloxs logic, 100 - -math.huge = math.huge.. why?

I do not have a clue

There’s IEEE 754 that defines that infinite values can be “packed” into numbers.
So technically on systems that support the standard Luau’s math.huge is not a number at all and thus math operations are not available.

1 Like

So then, I have a question; how would you guarantee that 100 - (-math.huge) would equal -inf? I’m trying to use it in some coding and it won’t budge.

100 - (-math.huge) equals inf not -inf bludimir its basic math

Okay, (100 - -math.huge) then? I’d presume the same thing.

its the same thing

Hmmm, alright then what would be the best way to have a players health fully removed.. no matter what the max health is, so they die when damaged in a numeric format?

set the health to 0

Health regenerates faster than it can keep up, and outside of disabling said healing script.. not sure what else to do

just make your own health system then

If you set the humanoid’s health to 0 it will instantly die and won’t regenerate because that’s how roblox designed their system… there’s no risk whatsoever

1 Like

huh, that never worked for me before.. the more you know.

oh thanks i really appreciate it

1 Like

because anything plus infinity is infinity genius

1 Like