+1 vote

How to get min and max numerical limits of float and int types?

Like a std::numerical_limits in C++

in Engine by (246 points)

1 Answer

+2 votes
Best answer

Hi,
godot does only have one int and one float type.

https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_basics.html#built-in-types

The int then has 2 ^ 63 max value + 1 bit for +/- sign

The float max value is much higher but looses precission due to the exponent

https://en.wikipedia.org/wiki/Double-precision_floating-point_format

int

Short for "integer", it stores whole numbers (positive and negative). It is stored as a 64-bit value, equivalent to "int64_t" in C++.

float

Stores real numbers, including decimals, using floating-point values. It is stored as a 64-bit value, equivalent to "double" in C++. Note: Currently, data structures such as Vector2, Vector3, and PoolRealArray store 32-bit single-precision "float" values.

by (3,132 points)
selected by

They should to create some numerical constants. I don't want that my games become broken when they decide to change that limits

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.