Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using a flexgrid

To format the output of my float to the grid I am using

C++
output.Format("%2.0f",value)


and this is rounding up my float(value) to an integer after this command, say value was 8.5 output is 9 which is then sent out to the flexgrid


any ideas please ?
Posted
Comments
Sergey Alexandrovich Kryukov 8-Mar-13 17:55pm    
Not a valid question. You forgot to tell us what formatting results do you want to get.
After all, learn floating-point formatting, it's just one page...
—SA

1 solution

Your format string specifies no digits after the decimal point so it will naturally round the value. Try ...
C++
output.Format("%5.2f",value)

... and it's always a good idea to read the documentation.
 
Share this answer
 
v2
Comments
Jakey777 9-Mar-13 8:39am    
Thanks Richard that worked. Found the appendix in the back of my C book, but not very helpful !
Richard MacCutchan 10-Mar-13 4:25am    
Take a look also at C-style format specifications.

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