Go Down

Topic: How to round a number or float to integer. (Read 5 times) previous topic - next topic

Marsheng

pow(XX,YY) creates a float.

How do I convert it back to integer ?

Thanks

Groove

Assign it to an integer type, but this truncates.
If you want rounding, add a half first.
Per Arduino ad Astra

Marsheng

I was using

Serial.print(pow(val,3));  and wanted and integer but found this workaround.

Serial.print(pow(val,3),0);          



Go Up