Hi,
is there an easy way to "round up"?
2.2 --> 3
2.7 --> 3
2 --> 2
I could trunc() and add 1, but than I would have to check for the third case.
So is there an easier way to do?
Hi,
is there an easy way to "round up"?
2.2 --> 3
2.7 --> 3
2 --> 2
I could trunc() and add 1, but than I would have to check for the third case.
So is there an easier way to do?
Add a half and truncate.
2.2 does not normally round to 3.
ceil() does just that, it is the brother of floor() , trunc() and round()
void setup()
{
Serial.begin(115200);
int x = ceil(2.2);
Serial.println(x);
int y = ceil(2.7);
Serial.println(y);
int z = ceil(2.0);
Serial.println(z);
}
void loop()
{
}