I don't know it my nomenclature is correct! Anyway, these are the integer I have, for example :
76
121
9660
And I'd like to round them to the close hundred, such as they must become :
100
100
9700
How can I do it faster in C#? I think about an algorithm, but maybe there are some utilities on C#?
Try this expression:
Try the
Math.Round
method. Here's how:If you only want to round integer numbers up (as the OP actually did), then you can resort to this solution:
If you want to perform floating-point (or decimal) rounding, then resort to the answers of @krizzzn and @Jim Aho.
I know this is an old thread. I wrote a new method. Hope this will be useful for some one.
Example:
Hi i write this extension this gets the next hundred for each number you pass
Note: I haven't tested this thoroughly.