# Delphi/Lazarus: Round Number to the next 10, 100 or 1000

Question by Guest | 23/01/2016 at 13:58

I have already read the tutorial about how to round to a specific number of decimal places in Delphi and Lazarus.

However, I am now interested in rounding before the decimal separator (comma or digit) instead of after it. I mean, I would like to round to the tens, hundreds or thousands digit of a number. For example, I would like to turn 12345 to 12340, 12300 or 12000.

Is there also a function available for that?

## Related Topics

Tutorial | 0 Comments

## Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

## Participate

Ask your own question or write your own articles on askingbox.com. How to do.

## Delphian

Show Profile | Message2 Votes

Yes, that is a function for that and you can even use the same function like you have used for rounding decimal places.

Here is an example:

Depending on whether you are passing a positive or negative value to the function RoundTo, it is rounded before or behind the decimal separator. So, in order to round to ten, you have to pass 1. If you would like to round to hundred, you have to pass 2. Accordingly 3 for the thousands digit.

Important: To make it work, you have to add the unit Math. and if you do not want to use this unit, here are some more ideas to solve this task.

23/01/2016 at 14:14