Rounding decimals to interger

  • Thread starter Thread starter Franck
  • Start date Start date
F

Franck

i would like to know how can i round to next greater than integer if
not integer already
what i mean is:

5.00000000000000000000000001 rounded to 6
5.1 rounded to 6
5.7 rounded to 6
6.0 rounded to 6
5.0 rounded to 5
as long as the value have something in decimal round it to the nearest
integer greater than
 
Franck said:
i would like to know how can i round to next greater than integer if
not integer already
what i mean is:

5.00000000000000000000000001 rounded to 6
5.1 rounded to 6
5.7 rounded to 6
6.0 rounded to 6
5.0 rounded to 5
as long as the value have something in decimal round it to the nearest
integer greater than

use Math.Ceiling

Christof
 
use Math.Ceiling

Christof

Works. i was trying whit split and everything :P but the problem was
depending on country the decimal symbol can be a dot or a comma. that
ceilling simplyfied my life there
 
i would like to know how can i round to next greater than integer if
not integer already
what i mean is:

5.00000000000000000000000001 rounded to 6
5.1 rounded to 6
5.7 rounded to 6
6.0 rounded to 6
5.0 rounded to 5
as long as the value have something in decimal round it to the nearest
integer greater than

Hi Franck,
You could use Math.Ceiling, like this:

decimal[] d = { 5.00000000000000000000000001M, 5.1M, 5.7M, 6.0M,
5.0M };
decimal[] d2 = new decimal[d.Length];
for (int i = 0; i < d.Length; i++)
d2 = Math.Ceiling(d);

John
 

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

Similar Threads

Round up 10th of Decimal 1
Round Function 5
Round formula 1
Rounding 2
Access stripping decimal places in query 1
Round to next value 4
Rounding problem 9
Number Field Automatically Rounding Decimals 3

Back
Top