Re: greatest multiple algorithm



Bronson <pshemu@xxxxxxxxx> writes:
Hi,

i'm looking for a fast way to find greatest multiple of a, which is
smaller than b.
Recently i've used b-b%a, but maybe it could be done faster.

Any ideas?

floor(b/a)*a

If a is known in advance and within certain ranges, that's
two operations.

Phil
--
"Home taping is killing big business profits. We left this side blank
so you can help." -- Dead Kennedys, written upon the B-side of tapes of
/In God We Trust, Inc./.
.