Re: [Algorithms] Converting floats to a specific range
Brought to you by:
vexxed72
From: Danny K. <dr...@we...> - 2010-05-07 15:07:34
|
> > There's a standard C library function, fmod, that nearly does what you want. The one thing you need to fix is that fmod(x, wrapSize) is negative whenever x is. So the solution to your problem is A quick unlurk - I've often wondered why mod functions always seem to do this. Can anyone explain that? I can think of very few occasions when you want to take the mod of a number and not restrict it to a single range, rather than maintaining the positive or negative value. I understand that doing it this way makes the function faster, but given that you usually have to override it anyway that would seem a bit of a meaningless saving. Danny > > |