How can I round up a decimal number to the nearest whole multiple of the same number?

39 Views Asked by At

I want to round up a number with a decimal into the nearest whole number that is also a multiple of it.

For example we take the number 1.7777778 (16/9) and we round it up the way I want to we should get 16. which is a way I could calculate aspect ratio of monitors in case they use custom ratios.

1

There are 1 best solutions below

0
On BEST ANSWER

Every rational number can be written as m/n reduced to lowest terms (and every terminating or repeating decimal is rational). Then multiplying by n gives the integer m. If the number is not rational, there is NO n that will give an integer.