Hello community.
I've got a question about outputting decimal values less than 1 and greater than 0.
For example, if you have a variable of type double that holds the value 0.05, is there anyway to hide the decimal point and have the value output simply as 05?
I thought maybe that
cout << noshowpoint << 0.05;
would produce output of 05, but that still outputs the value 0.05.
Not sure if this would work, but you could try running the value into a stringstream to get a string, then getting a substring of only the part after the decimal. I don't think there is a stream manipulator to accomplish what you are looking for.
you can multiply it by 10,100,1000 so on until it's greater than 1, and then check that it is greater than one, then output what the original value (that was great than one).
for instance
1 2 3 4 5 6 7
int main()
{
float a = .05;
while(a < 1)
{a*10;}
cout << setw(2) << setfill('0') << a;
}
or at least a basic idea here
this doesn't check specifically if it is greater than one, but in theory should work :P