Link to home
Start Free TrialLog in
Avatar of bail3yz
bail3yz

asked on

How can I format a double to have only 2 decimal places? C++

I need to format a double so it only has 2 decimal places.. the length of the double is always different.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bail3yz
bail3yz

ASKER

That makes s = ".2f" for me?
Avatar of bail3yz

ASKER

sprintf(s, "%.2f", 322.33333);

Works.. needed the %..

Thanks!
sorry, not quite woken up yet.