Why does percentage format specifier multiply by 100?
You normally work with decimal percents inside of code, like 0.5
and 1.0
, but the user likes to see nice whole numbers with a percent sign tacked on the end.
Percent means "out of 100
" and clearly your decimal percents are out of 1
. Therefore, .ToString("p")
multiplies your number by 100
and then appends a percent sign.
It's just the definition.
If you don't want to multiply the value by 100 , just want the percentage % besides the value entered , i.e. VALUE.00 % if value entered otherwise default 0.00%, then the answer is
PERCENTAGE_FORMAT = "#0.00\%";
It definitely worked for me !!
As to the why, "percent" literally means "out of one hundred", so 50% is mathematically equivalent to 0.50
. As to formatting, why not just add a percent sign?
value + "%"
... or something like this:
value.ToString("#.00\\%")