It's simple to find out what the exact minimum and maximum values for Int
eger and Long
integer are in Kotlin:
Signed 32 bit Integer:
Int.MIN_VALUE // -2147483648
Int.MAX_VALUE // 2147483647
Signed 64 bit Integer:
Long.MIN_VALUE // -9223372036854775808
Long.MAX_VALUE // 9223372036854775807
But if I try to print Float
or Double
types' ranges for min
and max
values I'll get unbalanced numbers.
Signed 32 bit Floating Point Number:
Float.MIN_VALUE // 1.4E-45
Float.MAX_VALUE // 3.4028235E38
Signed 64 bit Floating Point Number:
Double.MIN_VALUE // 4.9E-324
Double.MAX_VALUE // 1.7976931348623157E308
Why are the positive and negative values in Float
and Double
types so different?
Use Float or Double ? The precision of a floating point value indicates how many digits the value can have after the decimal point. The precision of Float is only six or seven decimal digits, while Double variables have a precision of about 15 digits. Therefore it is safer to use Double for most calculations.
The value of this constant is positive 1.7976931348623157E+308.
The conceptual definition of MIN_VALUE
is different for integers vs floating-point numbers.
Int.MIN_VALUE
is the largest negative value.Float.MIN_VALUE
is the smallest positive value.In other words, 1.4E-45
is 0.00[40 zeroes]0014
, and not a very large negative number. The largest possible negative value is represented by -1 * Float.MAX_VALUE
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With