Could you help?

I’m having a problem.

I want to round up to the nearest number ending in 7.

The problem is I don’t know the number I’m gonna be rounding. It’s a variable.

For example it could be 2,134.78. I need it to round up to 2,137.

The first thing I thought was to round it to the nearest integer. In this example 2,135.

So the rounded integer we call it Z.

Now, with this integer (Z) I could probably find how much should I add to itself to sum up to 2,137.

Z could be (another example) 1,233. I need to add to Z this time 4 to go to 1,237 (which is the number I really want).

First thoughts was to subtract Z out of Z and then add some amount that gave me some number that with an if statement if it gave me a certain amount I could probably know how much to add to Z to get the number ending in 7.

I know that numbers ending in 0 need to add 7

Numbers ending in 1 need to add 6

Numbers ending in 2 need to add 5, etc.

What I need to know is how much should I add to an unknown number (or already rounded to nearest int) to get to the nearest number ending in 7.

Did you get it?

Thanks!

Privacy & Terms