how to always round numbers up

  • Thread starter Thread starter Aussie Rules
  • Start date Start date
A

Aussie Rules

Hi,

Whats the easiest way to round numbers up.

For example, a calculation that results in a value of 1.3 will round to 1,
and a calculation that results in 1.8 will round to 2.

My issue that I want the 1.3 to always round up to 2, as to round down to 1
results is short supply of stock, which is worse than an over supply.

My only thoughts is to manually add 0.5 to every number and therefore it
would have that effect, but is there a better way to do this ?

Thanks
 
Aussie Rules said:
Hi,

Whats the easiest way to round numbers up.

For example, a calculation that results in a value of 1.3 will
round to 1, and a calculation that results in 1.8 will round to 2.

My issue that I want the 1.3 to always round up to 2, as to round
down to 1 results is short supply of stock, which is worse than an
over supply.

My only thoughts is to manually add 0.5 to every number and
therefore it would have that effect, but is there a better way to do
this ?


Math.Ceiling


Armin
 
Aussie Rules said:
Hi,

Whats the easiest way to round numbers up.

For example, a calculation that results in a value of 1.3 will round to 1,
and a calculation that results in 1.8 will round to 2.

My issue that I want the 1.3 to always round up to 2, as to round down to 1
results is short supply of stock, which is worse than an over supply.

My only thoughts is to manually add 0.5 to every number and therefore it
would have that effect, but is there a better way to do this ?

Thanks

As the others said, Math.Ceiling(double). Just be aware of what it does for
negative values. The value for -7.1 will be -7. This is by design, but
often people want the value further from zero.
 
Back
Top