List Info

Thread: C-Sharp (C#) Group: Simple easy question regarding doubles (I think)




C-Sharp (C#) Group: Simple easy question regarding doubles (I think)
user name
2006-01-07 06:02:22
I'm looking for a way for a float to contain only two
decimal places.
For example, I am doing this... fileSize /= MB_SIZE; but it
leaves me
with a ton of 10 or more decimal places. I only want two.
Thanks in
advance.

C-Sharp (C#) Group: Re: Simple easy question regarding doubles (I think)
user name
2006-01-07 17:45:06
Two decimal places is a display issue, you shouldn't care
how many are
actually stored, or if you do, you want the greatest
precision
possible. To print it out as two,do
var.ToString("N2")

Gabe wrote:
> I'm looking for a way for a float to contain only two
decimal places.
> For example, I am doing this... fileSize /= MB_SIZE;
but it leaves me
> with a ton of 10 or more decimal places. I only want
two. Thanks in
> advance.

C-Sharp (C#) Group: Re: Simple easy question regarding doubles (I think)
user name
2006-01-10 18:48:03

Add the format strnig {0:f3}
 
Thanks
Sekhar

 
On 1/7/06, Gabe < floresggmail.com">floresggmail.com> wrote:

I'm looking for a way for a float to contain only two decimal places.
For example, I am doing this... fileSize /= MB_SIZE; but it leaves me
with a ton of 10 or more decimal places. I only want two. Thanks in
advance.


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )