Since you are having difficulties in understanding floor, let me briefly describe it to you.
floor(x) = the greatest integer less than or equal to x
So
floor(2.99) = 2
floor(2.00) = 2
floor(-0.99) = -1
Why floor(N/8)*8 works?
We want the greatest multiple of 8 less than or equal to N?
So we want to remove as many 8 as we possibly can until it is greater than 0.
206-8-8-8-8-8-....8=6
Beyond this if we subtract 8 it goes below 0.So we stop here.
An important observation is that division is simply repeated subtraction.
This means dividing 206/8 gives us the number of 8's that can be subtracted from 206.
When the input number is limited to positive numbers, then you can simply use integer division in C++. This is because, when you carry out integer division in C++, the result is truncated.
That is 8/3 will be set to 2.
Though 8/3 is 2.66, the result is only the integer part.The fractional part is simply ignored.(This is just a simple explanation, for negative integers, you need to follow )
So in C++, you can simply write:
((N)/8)*8
Please don't just use something because it works, try and find out why it works!