Does the number of digits in a number in a math operation affect performance

title is pretty self explanatory

edit: including scenarios with decimals with a buncha digits

No, it does not. A computer is very powerful and processors are designed to handle loads of calculations. Number calculations costs next to nothing.

1 Like

well wht bout numbers in things like vector3 calculations

Vector3 is just a construct that contains 3 numbers. It’s the same as declaring 3 separate variables for the X,Y,Z components.

1 Like

When doing additions with Vector3 or any other data type. The computer checks what it’s operating on and handles it in the background.

For example, if you have 3 variables which are X, Y and Z. You can add them together and get a result.

X + Y + Z = Some result

If you were to add two Vector3 variables. The computer would be doing something like this in the background:

FirstVector = new Vector3()
SecondVector = new Vector3()

FirstVector + SecondVector is handled internally like this:

Resulting Vector3 = Vector3.new(FirstVector.X + SecondVector.X, 
FirstVector.Y + SecondVector.Y, 
FirstVector.Z + SecondVector.Z)

No. Internally, the numbers are stored with the same number of bits regardless of their size.

In other words, the computer doesn’t know that one of the numbers is 7 and the other is 70000. It just sees 64 bits and 64 bits.

1 Like