0/0 is 0 on IntValue?

When using 0/0 on an IntValue or any impossible mathematical operation it gives 0 while NumberValue gives nan. Why?
image

1 Like

You can’t do 0/0 because you can’t divide by 0. Also I don’t really know why number values make the result to 0.

Well I know that and I know it’s suppose to give nan or simply undefined but when using IntValue it gives 0, which by math law shouldn’t happen.

that’s weird how?

asdasdsafghdafgg

Maybe because it’s an IntValue it just rounds nan to 0? Just a guess.

2 Likes

This is actually really interesting. I set the value of a NumberValue to 5/0 (or literally any other number besides 0) and the result became infinity. In the case of limits, this is true so I’m interested in how mathematical operations are handled on Roblox’s end. :man_shrugging:

As the name suggests, the value of an IntValue is stored as an integer (a whole number), unlike the value of a NumberValue, which is stored as a floating point number. These floating point numbers have a way to represent NaN; however, integers do not.

As a result of this, whenever you attempt to assign a value that doesn’t have an integer form to an IntValue, it will default to 0.

4 Likes

It is expected. The division by zero always result in “not a number” or nan. You can see it via a graph demonstrating its value as x reaches 0 here.

However, IntValue doesn’t allow these nonsensical numbers and restrict itself to integers. Go read about the definition of integers.

1 Like

Actually, thinking about it, 0/0 is going to be 0.
The problem with any other number is that division by 0 is infinite.

It may explain why 0 as an integer is exactly 0, where a NumberValue may not be exactly 0.
:person_shrugging:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.