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 num input;
  • 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

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -