LojiSmith
LojiSmith

Reputation: 290

Data showing in Exponential format

My data 0.00007173535 is showing as 7.1735351E-05 in aspx page.

My required format is decimal even the number has 20 decimal points. I know its a small thing but couldn't figure it out.

My code is below that is in a repeater.

<%# Math.Round(Convert.ToDouble(Eval("Ranking.Rating")),12)%>

Upvotes: 1

Views: 128

Answers (2)

dav_i
dav_i

Reputation: 28137

Just call ToString(format) on it:

0.00007173535.ToString("0.0#################")

outputs

0.00007173535

or

0.00007173535.ToString("N12")

outputs

0.000071735350

See MSDN: Custom Numeric Format Strings for more information.


In your case this would be:

Convert.ToDouble(Eval("Ranking.Rating")).ToString("N12")

Upvotes: 1

Soner G&#246;n&#252;l
Soner G&#246;n&#252;l

Reputation: 98840

Or you can use "F" format specifier as well.

yourValue.ToString("F20");

Upvotes: 2

Related Questions