I am trying to write a prog that will allow input of float values and calculate profits from these values.I need to be able to print out a minus sign if the profits are negative and the '-' has to be on the right hand side of the output value.I have worked out that you can print a minus on the right by using %5.2f- but I need to test the value stored in the variable.
Is there an easy way to tell if the value stored in the variable is negative so I can use this format specifier .
What I'd like to do is use the ternary operator e.g.
(value<0) ? %5.2f- : %5.2f ; but this doesn't work
Any ideas gents?(or ladies(College Girl))
I'm not sure that I understand. If the value is negative, it will print as negative value (with the minus sign) you wont need to add a '-' character.
If you want to change the sign you could do
value = -value;
Yeah if the value is negative it will reflect this in were ever store the value.
I might not be understanding your question.