Format double to x numbers.

  • Thread starter Thread starter bojan.pikl
  • Start date Start date
B

bojan.pikl

Hi,

I need to find a way to format (round) double to x numbers length.
So .ToString("0.000"); is not good because it has fixed length (in
example 5). I then later parse Double to String, so I can also format
String. But it should not be substring because then the numer is not
correct. (If you just cut the end).

Does anyone know the way to do this?
 
Nobody knows?

What I want is:
let's say

x=4; //max length of number

double a,b,c;
String s;

a=23,45;
b=25,9;

c=607,355;

s=c.ToSting();

display(s);

When I display s I want to be displayed as 607,4 (c rounded to 4
numbers length) or in exponental (but again on 4 places).
 
Use Math.Round(double, precision)

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

What You Seek Is What You Get.
 

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

Back
Top