How to make a number as a multiple of X?

Let say, I have a multiple 8. I have a initial value 48.7936628598344. Now, I need to make sure that 62 come in the series when I add multiple 8 with it's initial value.

Currently, 62 is not coming in the series.

48.7936628598344 + 1 * 8 = 56.79366286,

48.7936628598344 + 2 * 8 = 64.79366286,

48.7936628598344 + 3 * 8 = 72.79366286

What should I do the initial value 48.7936628598344

• Got it, 48.7936628598344 + ( Mod(62,8)- Mod(48.7936628598344,8) ) = 54. Any suggestion will be appreciated. – user960567 Apr 13 '12 at 14:02
• I have no idea what is going on here. What are you trying to do, construct a sequence here that starts at 48.whatever, eventually takes the value 62, and is somehow constructed via multiples of 8? – Neal Apr 13 '12 at 14:25
• Please try to explain a bit better. – GarouDan Apr 13 '12 at 14:28
• You have not provided any additional constraints, so you could just change the initial value to 62-8, right? – Rafał Dowgird Apr 13 '12 at 14:40
• @RafaĆDowgird, You are correct but I need the number should be should be as near to 48.7936628598344 as possible. – user960567 Apr 14 '12 at 7:06

Let's suppose that you search $n$ such that $62-8n$ is nearest of your input value $x$ then : $n=\operatorname{round}\left(\dfrac{62-x}8\right)$ so that the wanted integer could be : $$N=62-8\cdot\operatorname{round}\left(\dfrac{62-x}8\right)$$ If you want an integer larger than your input $x$ then use rather : $$N=62-8\cdot\operatorname{floor}\left(\dfrac{62-x}8\right)$$ (I'm supposing that you use a language 'C-like' where $\operatorname{floor}(x)$ returns an integer smaller than $x$)
• @user960567: Let's use your $x=48.7936628598344$ then $n=\operatorname{round}\left(\dfrac{62-48.7936628598344}8\right)=2$ so that $N=62-2\cdot 8=46$ for the first and $n=1$, $N=54$ for the second. – Raymond Manzoni Apr 14 '12 at 9:21