Formating numbers

C

cmdolcet69

Im having this problem with Formatting numbers.......In any case I
declare a variable intvalue as double....when i look at what values
are being written out in the text file i see two different values.the
first value is 0.01 and the second value is 0.0099999998 how can I
format the number to 2 decimal places???
 
R

rowe_newsgroups

Im having this problem with Formatting numbers.......In any case I
declare a variable  intvalue as double....when i look at what values
are being written out in the text file i see two different values.the
first value is 0.01 and the second value is 0.0099999998 how can I
format the number to 2 decimal places???

Math.Round()?

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
A

Armin Zingler

cmdolcet69 said:
Im having this problem with Formatting numbers.......In any case I
declare a variable intvalue as double....when i look at what values
are being written out in the text file i see two different
values.the first value is 0.01 and the second value is 0.0099999998
how can I format the number to 2 decimal places???

How do you convert the number to a String? If you don't do it on your own
(by passing it to a method that does the conversion), do it now:
value.ToString("0.00")

The documentation contains chapters about this once again:
http://msdn.microsoft.com/en-us/library/fbxft59x.aspx


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top