Ask your own question, for FREE!
Computer Science 10 Online
OpenStudy (davidusa):

C PROGRAMMING- Help- how to use the round( ) function and round a float to the nearest hundredth?

OpenStudy (davidusa):

@confluxepic @maddiegirl @e.mccormick Please help :)

OpenStudy (davidusa):

How do I use the round( ) function in the math.h library to round a float to the nearest hundredth? I want to avoid float imprecision, that's why.

OpenStudy (davidusa):

@maddiegirl you there...???

OpenStudy (davidusa):

@Whitemonsterbunny17

whitemonsterbunny17 (whitemonsterbunny17):

Maybe @iambatman can help? I don't know this stuff, sorry.

OpenStudy (e.mccormick):

http://www.cplusplus.com/reference/cmath/round/ I do not see it taking any arguments for precision, so the only thing I can think if is to multiply by 100, round, then divide by 100, or use a different function.

OpenStudy (e.mccormick):

Another suggestion is: floor(x*100+0.5)/100; That will add a half to the lowest value then round it down. If you are at .5 or higher on the last digit, post multiplication, it will round up. For .4 to .0 it will round down.

OpenStudy (davidusa):

@e.mccormick Thanks for the help.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
23 hours ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!