Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove E sign from big float number , C#?

If you used big float numbers , you found in C# big float number is showed like this :
2000000 * 2000000 = 4E+12

How can I show 4E+12 as 4,000,000,000,000 not 4E+12 ?

like image 992
Mohammad Dayyan Avatar asked Dec 12 '10 17:12

Mohammad Dayyan


People also ask

What does E mean in float?

the character "E" means 200 zeros after the "."

Why float is not accurate?

Floating-point decimal values generally do not have an exact binary representation. This is a side effect of how the CPU represents floating point data. For this reason, you may experience some loss of precision, and some floating-point operations may produce unexpected results.

How are floating point numbers represented in computer memory?

In computers, floating-point numbers are represented in scientific notation of fraction ( F ) and exponent ( E ) with a radix of 2, in the form of F×2^E . Both E and F can be positive as well as negative. Modern computers adopt IEEE 754 standard for representing floating-point numbers.


1 Answers

You want

number.ToString("N0");

"N0" is Number with no decimal places.

The alternative - "F0" is Fixed-point with no decimal places but prints without the comma separators:

double number = 4e12;
Console.WriteLine(number.ToString("F0"));
Console.WriteLine(number.ToString("N0"));

prints:

4000000000000
4,000,000,000,000

Source

like image 162
ChrisF Avatar answered Sep 20 '22 04:09

ChrisF