0

How to round to hundredths?

Input: a=3,141592 b=5,566 Output: a=3,14 b=5,57

30th Mar 2020, 4:58 PM
PUFFIN Channel
PUFFIN Channel - avatar
3 Antworten
+ 2
Multiply by 100, rounddown, and then divide by 100. Include standard math library to use floor function https://code.sololearn.com/cAdE12itxlps/?ref=app
30th Mar 2020, 5:10 PM
Gordon
Gordon - avatar
+ 2
The earliest way is to set precision std::precision(number of positions +1); https://code.sololearn.com/coguS2kSsZaw/?ref=app
30th Mar 2020, 6:28 PM
BroFar
BroFar - avatar