为什么百分比的标准数字格式包含一个空格? [英] Why does the Standard Numeric Format for percentages include a space?
问题描述
我有一些十进制值,作为较大字符串的一部分在网页上显示为字符串.我开始使用标准数字格式字符串来输出它.例如
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 Standard Numeric Format String to output this. E.g.
myDecimal.ToString("P0")
P
后面的 0
告诉它我不需要小数位.就目前而言,这有效,因为我的输出最终看起来像:
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:
上述计算基于2%的阶段性最低公司贡献率
Calculated as above based on the phased minimum Company contribution rate of 2 %
空间问题
我真的很想去掉数字和百分比符号之间的空格,因为在某些情况下它最终会跨行拆分.而且,我更喜欢用 % 来表示数字.
The Space Problem
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.
我可以在它周围放一个 <nobr>
标签或 <span style="white-space: nowrap;">
.但是,这感觉很尴尬,无论如何,我更喜欢将 % 与数字对接,因为我认为它看起来更好.这就是我们在这个树林的脖子上写报告的方式,所以这就是我想要在网页上的方式.
I 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 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.
推荐答案
查看 http://www.nasdaq.com/ 或 http://finance.yahoo.com/ 似乎后面的百分号中间没有空格的数字很常见:)
Looking at http://www.nasdaq.com/ or http://finance.yahoo.com/ it seems that the percentage sign right after the number with no space inbetween is common :)
这可能取决于文化,默认(不变)beeing n %
It probably depends on culture, the default (invariant) beeing n %
这篇关于为什么百分比的标准数字格式包含一个空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!