rounding - c++ upper value calculation -


I have double variable double dub 1. If this is a multiplier of integer 15, then I want to get the result of division (like 30/15 -> 2) if this integer is not multiple, then I think the upper value (like 20/15 -> 2 OK) I want to score with How do I handle the first part?

  int divres = dub1 / 15; // divres ++ for the second part;    

& lt; Cmath & gt; Use the function located in ,:

  int divres = static_cast & lt; Int & gt; (Std :: ceil (dub1 / 15)); You can use   

OK, without roofing , as follows:

  int divres = dub1 / 15; If (std :: fmod (dub1, 15)! = 0) {divres ++; }    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -