Why can I not make my value on an IntValue equal infinity?

I am trying to make a gun with infinite ammo, but I do not know how to set this value to infinity, besides writing the number 9 over and over again.

1 Like

An IntValue should be able to hold math.huge which would be the closest thing to infinity.

2 Likes

This is not true. I have to ask, where did you get this from and why do you think a 64-bit signed integer should be able to hold infinity as all its binary representations for IntValues are in two’s complement 64-bit binary integer with all of them in integer? math.huge isn’t the closest thing to IEEE 754 infinity, it is IEEE 754 infinity

math.huge is not a property of a 64-bit signed integer. It’s a property of an IEEE 754 floating point value, IntValues is not an IEEE 754 floating point value. IntValues (64-bit signed integers) can only hold integers from -263 to 263.

(Though to OP may I ask, why not use a NumberValue instead of an IntValue as there’s no Integers in Lua(u)?)

While you can definitely set something to be math.huge value, your closest bet to truely infinite ammo is to just give that gun the specialty through scripting.

Just remove the part of the code that lowers ammo value by 1 per shot.

OP clearly stated it’s an IntValue (so I assumed you meant IntValues) and I clearly said that math.huge is not a property of an IntValue. I’ll repeat myself and I have to ask again, where did you get the fact that you can set IEEE 754 Infinity to a 64-bit signed (probably) two’s complement integer?

What makes this closer to setting it to IEEE 754 infinity? Really, it would result in the same thing.

I was just referring to the solution since apparently he thought it worked. I don’t actually know if you can set it to math.huge. It’s a large edge case since I don’t expect to do it either.

I mean closer to infinity as in that it would never become 0 in ammunition. I don’t literally mean setting ammo to infinity. Done through coding whatever makes the gun consumes ammo in the first place.

1 Like