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 CRank #369 · 6.8K reputationPosted Sep 9, 2021, 6:06 AM EDT
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Sep 9, 2021, 5:37 AM EDT
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
Valerie MeunierRank #1,527 · 1K reputationPosted Sep 9, 2021, 6:45 AM EDT