Requirement is to format a decimal number to a string, but with a maximum of 10 digits in total, for example:
Using {0:0.######} obviously doesn't work because it doesn't take into account the total number of digits... is there a formatting string that does this kind of formatting, or does it require extra code to achieve this?
EDIT: I'm trying to set a cell format with Aspose.Cells using the Custom property on the style of a cell. It seems that G10 doesn't work.
Probably, you're looking for "G10"
format string
Double s = 7846.05368740952;
// 7846.053687
String result = s.ToString("G10");
this formatting works with Decimal
as well:
Decimal d = 47585.7350421593M;
// 47585.73504
String result = d.ToString("G10");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With