Hi, is there a quick way to format a float variable that is 0.775 to display it as 77.5? Thanks

To better clarify, im doing a simple little tasks of

variable = variable / variable to find the percentage of something.

Multiply by 100. (Isn't that an elementary school question?)

hah, I didn't even think of that lol. Thanks for the obvious answer =D

I think there is a way to do it by manipulating the output stream's formatting, but I'm not totally familiar with that yet.

In the meantime, you could just multiply by 100 when you output it.

float percent = 0.0f;
float value1 = 12.0f;
float value2 = 48.0f;

percent = value1 / value2;

std::cout << "Your percentage is: " << (percent * 100) << std::endl;

EDIT:
Looks like Dave beat me to it...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.