Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in float after decimal point i want to show only two value
Posted

Use proper format specification fields of printf [^]. For instance
float x = 1.237f;
printf("x=%8.2f\n", x);


As you may observe (the output is x = 1.24), the value is rounded.
:)
 
Share this answer
 
use sprintf to format your floating point number into a string that has the format you desire. I assume you're really using C, and not C# ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900