Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maximum value for type float in c#

Tags:

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 without this symbol?

msdn says RANGE: ±1.5 × 10^−45 to ±3.4 × 10^38, but that did not help me.

like image 701
Tyrael Archangel Avatar asked Aug 08 '12 04:08

Tyrael Archangel


People also ask

Is a float always 4 bytes?

Yes it has 4 bytes only but it is not guaranteed.

What is maximum precision value of float data type?

Precision: 6 to 9 significant digits, depending on usage. The number of significant digits does not depend on the position of the decimal point.

What is the value of float in C?

Float is a datatype which is used to represent the floating point numbers. It is a 32-bit IEEE 754 single precision floating point number ( 1-bit for the sign, 8-bit for exponent, 23*-bit for the value.


1 Answers

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

like image 56
Dan Avatar answered Sep 19 '22 08:09

Dan