Search code examples
c#.netrounding

How to round a decimal up?


Given a decimal '96.154', how can I ensure that it is always rounded up to 96.16 (as opposed to normal rounding to 2 decimals which would give 96.15).


Solution

  • Kind of hacky but a very intuitive way to do so:

    var val = 96.154M;
    
    var result = Math.Ceiling(val * 100) / 100.0M;