On Tue, Jun 24, 2014 at 05:16:08PM +0200, Martti Kühne wrote: > True. > Hence, and following other sources about this topic [0], I suggest > > #define CEIL(x) ((int)(x) + ((int)(x) > 0) * ((x - (int)(x)) > FLT_EPSILON)) > > cheers! > mar77i > > [0] > http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
I think that's still inaccurate. I don't think the standard ceil(3) takes into account machine epsilon deltas: ~% python Python 2.7.7 (default, Jun 3 2014, 16:16:56) [GCC 4.8.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import math >>> import numpy >>> math.ceil(np.finfo(np.float64).eps) == 1 >>> math.ceil(numpy.finfo(numpy.float64).eps) == 1 True The clause "np.finfo(np.float64).eps" returns the epsilon value. Eric