maximum value for type float in c#

前端 未结 8 1616
你的背包
你的背包 2021-02-12 14:27

when i do this:

float x = float.MaxValue;

I have the result: 3.40282347E+38

What is E+38? how can I represent the maximum number withou

相关标签:
8条回答
  • 2021-02-12 15:30

    The "E+38" format is the default. If you'd like to see the whole number, specify a different format like this:

    float.MaxValue.ToString("#")
    

    This will result in:

    340282300000000000000000000000000000000
    

    Here are some additional formats: http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.aspx

    0 讨论(0)
  • 2021-02-12 15:30

    This is called E-Notation (exponential notation), and is used with scientific notation.

    From the E Notation section of the Wikipedia article on Scientific Notation:

    Because super-scripted exponents like 10^7 cannot always be conveniently displayed, the letter E or e is often used to represent times ten raised to the power of (which would be written as "x 10^b") and is followed by the value of the exponent.

    So, 3.40282347E+38 equals 3.40282347 * 1038 and would be read "3.40282347 times 10 to the power of 38".

    0 讨论(0)
提交回复
热议问题