The Back Story
I have some decimal values which I am displaying as strings on a web page as part of a larger string. I started off using a http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx]">Standard Numeric Format String to output this. E.g.
myDecimal.ToString("P0")
The 0
after the P
tells it I want no decimal places. This works as far as it goes, in that my ouput ends up looking something like:
The Space ProblemCalculated as above based on the phased minimum Company contribution rate of 2 %
I really want to get rid of that space between the number and the percentage sign as in some cases it ends up splitting across lines. And also, I prefer the % to butt up to the number.
Possible Workarounds
1. html / css solutionI could put a <nobr>
tag or a <span style="white-space: nowrap;">
around it. But, that feels awkward, and anyway I prefer the % to butt right up to the number as I think it looks better. It's how we would write it in reports in this neck of the woods, so it's how I want it on the web page.
I am going to end up using a http://msdn.microsoft.com/en-us/library/0c899ak8.aspx]">Custom Numeric Format String, E.g.
myDecimal.ToString("0%")
The Question
Is it more common to display percentages with a space between the number and the percentage sign? This would surprise me, but it could be.
Is there a way to tell the Standard Numeric Format String I don't want the space?
Is there any disadvantage to using a Custom Numeric Format String over a Standard Numeric Format String?
Ok - I admit it, that was more than one question - Extra Credit if you answer them all.