Hi,
Console.Write("Input numeric value: ");
float g1 = Convert.ToSingle(Console.ReadLine());
Console.WriteLine(g1);
When i input 10,1457854, i get 10,14579
When i input 100,1457854, i get 100,1458
When i input 1000,1457854, i get 1000,146
How come and how to get always 4 decimals?
Thanks
Ganesan CPosted Sep 9, 2021, 10:06 AM
Valerie MeunierPosted Sep 9, 2021, 10:45 AM
Srinivasan RamamoorthiPosted Sep 9, 2021, 9:37 AM
The float data type has only 6-7 decimal digits of precision. That means the total number of digits, not the number to the right of the decimal point. You have to use decimal data type