Re: [Algorithms] Converting floats to a specific range
Brought to you by:
vexxed72
From: Simon F. <sim...@po...> - 2010-05-07 12:06:16
|
Zafar Qamar wrote: > Hi, > > I'm sure this problem is pretty simple, but here goes... > > I have a set of float numbers that I'm trying to auto-wrap within a > specific range of 0.0 to wrapSize (wrapSize is positive, and not a > power of 2) > > > Can anyone think of a bit of maths for this please? Note that it > needs to work for any positive value of wrapSize (not just 1.0) > > Cheers > Zafar Do you mean like multiplying by the reciprocal of your range, taking frac, and scaling back up again? Simon PS: I hope you don't need this to be accurate for huge values (e.g. in range reducing operations for, say sin(maxfloat)) |