
26 Oct
2010
26 Oct
'10
4:06 p.m.
Hello all, I couldn't find a functionality like 'round to fraction', which would try round a floating point value to its nearby fraction portion: round2fraction(1.4, 0.5); -> 1.5 round2fraction(1.8, 0.5); -> 2.0 round2fraction(1.0, 0.5); -> 1.0 round2fraction(1.25, 0.5); -> 1.5 round2fraction(-1.6, 0.5); -> -1.5 We have here a private implementation, but this is probably not as optimised as those numerical guru's can come up with. Is this a good suggestion to add to Boost.Math or overkill?