c++ - Can I build this special rounding function with Standard Library components? -
is there, in c++ standard library, way obtain func function behaviour :
- takes double
numinput; - returns highest integer strictly inferior
num.
i emphasize strictly, because if read ‘inferior or equal’ of course ceil function job.
what want : func(3.1) equals 3, func(3.9) equals 3, importantly func(4) equals 3 well, , not 4. idea implementation ?
ceil(x)-1.0 should work. when x not integer, ceil(x)-floor(x)=1, , when x integer, ceil(x)=x, ceil(x)-1 want.
Comments
Post a Comment