0
Can someone see why my last event in Duct Tape challenge dosent want to be true?
Here is my code: https://code.sololearn.com/cK1Xpo1rFS4i/?ref=app
4 Antworten
0
Manually adding 0.5 is not guaranteed to round the number up, but you will always need to buy a full roll of duct tape even if a portion would be sufficient. You could use the standard ceil() function instead:
#include <cmath>
...
numberRollTSI = ceil(numberRollOS * 2);
0
Shadow
Worked!
If you have the time, can you explain what this function does?
I want to understand this function so I can use it on other code.
0
It simply rounds a decimal number up to the nearest integer, e.g.
ceil(0.1) = 1
ceil(0.5) = 1
ceil(1) = 1
ceil(-0.5) = 0
See:
https://en.cppreference.com/w/cpp/numeric/math/ceil
There are similar functions for rounding down, rounding to the closest integer, etc. in the standard library.
0
Shadow
Alright! I understand now.
thank you so much for your help!