Re: Converting floats to a specific range
"Simon Fenney" <[email protected]> Fri, 7 May 2010 12:50:28 +0100
| Newsgroups | gmane.games.devel.algorithms |
|---|---|
| Message-ID | <[email protected]> |
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)) ------------------------------------------------------------------------------ _______________________________________________ GDAlgorithms-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list