T
Tasperian Jigs
Hi,
I try to get a 'next value' (depending on 'nextNumber') for a double with
this method.
public static double nextNearest(double value, double nextNumber)
{
final double remainder = value % nextNumber;
return value - remainder + (remainder > 0 ? nextNumber : 0);
}
But the 'remainder' variable does not get the exact remainder after the
modulus. Is there another way to realise this method so the return result
is the exact double that i want? I'm aware of floating point inaccuracies,
that's why I ask this question ..
Thanks,
J
I try to get a 'next value' (depending on 'nextNumber') for a double with
this method.
public static double nextNearest(double value, double nextNumber)
{
final double remainder = value % nextNumber;
return value - remainder + (remainder > 0 ? nextNumber : 0);
}
But the 'remainder' variable does not get the exact remainder after the
modulus. Is there another way to realise this method so the return result
is the exact double that i want? I'm aware of floating point inaccuracies,
that's why I ask this question ..
Thanks,
J