+ 2

hi. how to round off float number to 2 decimal place?

8th Nov 2017, 6:12 AM
Siti Nor Amirah Binti Mustaffa
Siti Nor Amirah Binti Mustaffa - avatar
3 Antworten
+ 3
heres code i found online that might help #include <math.h> float val = 37.777779; float rounded_down = floorf(val * 100) / 100; /* Result: 37.77 */ float nearest = roundf(val * 100) / 100; /* Result: 37.78 */ float rounded_up = ceilf(val * 100) / 100; /* Result: 37.78 */
8th Nov 2017, 6:23 AM
Enzo
Enzo - avatar
0
thank u 😊
10th Nov 2017, 8:16 AM
Siti Nor Amirah Binti Mustaffa
Siti Nor Amirah Binti Mustaffa - avatar