What Is the Max Value for 'Float'? [Duplicate]
When I Check the Value of "Float. Maxvalue" I'm Getting: 3.402823E+38 Which Is: 340,282,300,000,000,000,000,000,000,000,000,000,000 Then Why When I'm Trying to...
When I check the value of "float.MaxValue" I'm getting:
3.402823E+38
which is:
340,282,300,000,000,000,000,000,000,000,000,000,000
Then why when I'm trying to set a much smaller value into a float variable:
float myValue = 1234567890123456789024;
then I get an error message:
"Integral constant is too large" ?
This value is MUCH smaller then "3.402823E+38", so why am I getting an error for it?
Most Numeric types have a MaxValue Field
Represents the largest possible value of Single. This field is constant.
Which equates to
public const float MaxValue = 3.402823E+38;
However in this case, you need to put use f suffix to specify a type of a numerical literal, otherwise it will interpret it as an integral type (on a cascading scale of max range up to uint64).
float myValue = 1234567890123456789024f;
Additional Resources
Value types table (C# Reference)
Integral constant is too large
A value represented by an integer literal is greater than UInt64.MaxValue.
Represents the largest possible value of UInt64. This field is constant.
public const ulong MaxValue = 18446744073709551615;