Reputation: 1112
I used:
Result_TextBox.Text = result.ToString(".#######"); //result is double
But if the result is 100.0000000, it becomes 100. What should I use in order to keep the accuracy of 7 decimals place?
I tried:
Result_TextBox.Text = Math.round(result, 7); //but this is effective at all, why?
Please help
Update: can someone explain "#" and "0"?
Upvotes: 0
Views: 621
Reputation: 2057
There is a Standard numeric format strings for that.
You can use The Fixed-Point ("F") Format Specifier followed by a number to define the number of decimal digits.
Console.WriteLine(100.ToString("F7"));
// -> 100.0000000
Console.WriteLine(100.ToString("F3"));
// -> 100.000
Example : https://dotnetfiddle.net/EmPewm
Upvotes: 0
Reputation: 28771
This works
Result_TextBox.Text = result.ToString("#.0000000");
Upvotes: 2
Reputation: 3792
Use:
Result_TextBox.Text = result.ToString("0.0000000");
The second line doesn't work because you're trying to assign a numeric data type to a string without conversion.
Upvotes: 2