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

c# - passing input text from view to contoller with FacebookContext using Facebook app -

ios - Does Core Data autoupdate a many to many relationship on saving -

Calling a C++ function from C# by passing a string with variable size to it -