Home > Back-end >  Reduce a decimal precision by one place, always rounded up
Reduce a decimal precision by one place, always rounded up

Time:12-02

I'm trying to simplify a decimal value to always have one fewer digits. The result should always round up, never down.

For example, if I have 8.81 the should should be 8.9. If I have 2.566666 the result should be 2.56667.

How can I do this?

CodePudding user response:

I have a solution. My starting number is always 2 digits so i can use this:

Dim Number as double = 8.81 Dim result as double = Math.Ceiling(Number * 10)/10D

Thanks to @dbasnett for the seggestion.

  • Related