001 形式的数字
001这样的数字有没有特殊的名称? 例如,数字 20 是 020,1 是 001。
当你不知道某个东西的名字时,很难用 Google 搜索!
因为我已经在浪费你们的时间了,有谁知道一个可以改变的函数吗?数字转换成这种格式。
Is there a special name for numbers in the format of 001.
For example the number 20 would be 020 and 1 would be 001.
Its hard to Google around when you don`t know somethings name!
Since I am already wasting your guys time does any one know a function for changing numbers to this format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
试试这个:
Try this one:
它称为填充。
It's called padding.
好吧,如果您在某些编程语言的上下文中讨论该表示法,则与
20
相反的020
将是八进制而不是十进制。否则,您指的是填充。
Well, if you're talking about that notation within the context of certain programming languages,
020
as opposed to20
would be Octal rather than Decimal.Otherwise, you're referring to padding.
快速的谷歌搜索显示了这段很好的
数字填充
代码片段:http://sujithcjose.blogspot.com /2007/10/zero-padding-in-java-script-to-add.html
A quick google search revealed this nice snippet of code for
Number Padding
:http://sujithcjose.blogspot.com/2007/10/zero-padding-in-java-script-to-add.html
您可以使用一个简单的函数,例如:
或者一个更强大的函数,用您喜欢的任意字符填充左侧,例如
You can use a simple function like:
Or a more robust function that pads the left hand side with as many of whatever character you like, e.g.
它被称为左零填充数字。
Its called left zero padded numbers.
我认为这通常被称为“填充”数字。
I think this is usually called "padding" the number.