+ 1

how to convert 5.3333 to 5.33 in cpp

cpp based

4th Nov 2017, 5:39 PM
Samadhan Salunkhe
Samadhan Salunkhe - avatar
4 Answers
+ 6
universal answer for any language: 1. multiply with 100, 2. cast to integer 3. cast back to float/double 4. divide with 100
4th Nov 2017, 5:41 PM
Jeremy
Jeremy - avatar
+ 3
u can use fixed setprecision () function also or printf ("0.2f0.2f")
4th Nov 2017, 5:44 PM
Samadhan Salunkhe
Samadhan Salunkhe - avatar
+ 1
std::floor(), std::ceil() or round() from cmath
4th Nov 2017, 6:02 PM
deFault
- 1
can u please upvote my que
4th Nov 2017, 5:45 PM
Samadhan Salunkhe
Samadhan Salunkhe - avatar