Fastest possible scaled rounding
*Please note that I am aware of Math.Round thingy. This is a bit more complex question than it seems..*

I am trying to implement most efficient **scaled** rounding using C#. Scaled rounding is to find closest legitimate number. In my case legitimate number is y ~ x * n where y is input number, n is result of the scaled rounding and x is known number.

Implementation could be where x is always int or is always double (whichever solution will turn be faster). x and n are always positive.

example. I have x = 0.0625. And I have input number y = 0.1876. The algorithm need to find n which gives me x * n closest to y.... And be very efficitent CPU-wise! in this example n = 3 => 0.0625 * 3 = 0.1875, 0.0625 * 4 = 0.2500. 0.1876 close to 0.1875 than to 0.25

(I am also OK to use ints instead. it would be x = 625, y = 1876 and n = 3)

**Not using Math is encouraged.** it is going to run on Xeon E5.

Fastest possible scaled rounding
===

*Please note that I am aware of Math.Round thingy. This is a bit more complex question than it seems..*

I am trying to implement most efficient **scaled** rounding using C#. Scaled rounding is to find closest legitimate number. In my case legitimate number is y ~ x * n where y is input number, n is result of the scaled rounding and x is known number.

Implementation could be where x is always int or is always double (whichever solution will turn be faster). x and n are always positive.

example. I have x = 0.0625. And I have input number y = 0.1876. The algorithm need to find n which gives me x * n closest to y.... And be very efficitent CPU-wise! in this example n = 3 => 0.0625 * 3 = 0.1875, 0.0625 * 4 = 0.2500. 0.1876 close to 0.1875 than to 0.25

(I am also OK to use ints instead. it would be x = 625, y = 1876 and n = 3)

**Not using Math is encouraged.** it is going to run on Xeon E5.
