What is the full list of number suffixes in PowerShell?

我的未来我决定 提交于 2019-12-19 16:22:29

问题


What is the full list of suffixes you can use on PowerShell number literals?
So far I have found:

╔════════╦═════════╦════════════════════════╗
║ Suffix ║ Example ║         Result         ║
╠════════╬═════════╬════════════════════════╣
║   L    ║   1L    ║ Type = Int64           ║
║   D    ║   1D    ║ Type = Decimal         ║
║   KB   ║   1KB   ║ 1KB = 1024             ║
║   MB   ║   1MB   ║ 1MB = 1048576          ║
║   GB   ║   1GB   ║ 1GB = 1073741824       ║
║   TB   ║   1TB   ║ 1TB = 1099511627776    ║
║   PB   ║   1PB   ║ 1PB = 1125899906842624 ║
╚════════╩═════════╩════════════════════════╝

But I can't find a source that would list all of them.


回答1:


According to the PowerShell Language Specification (V3) that is the complete set.

  • §2.3.5.1.1 Integer Literals includes: l, kb, mb, gb, tb, and pb.
  • §2.3.5.1.2 Real Literals adds d.

As far as I am aware (no update to the specification has been published) PowerShell V4 does not add any further suffixes.




回答2:


The suffices are fully documented here.

y   signed byte data type           Added in PowerShell 6.2
uy  unsigned byte data type         Added in PowerShell 6.2
s   short data type                 Added in PowerShell 6.2
us  unsigned short data type        Added in PowerShell 6.2
l   long data type
u   unsigned int or long data type  Added in PowerShell 6.2
ul  unsigned long data type         Added in PowerShell 6.2
kb  kilobyte multiplier
mb  megabyte multiplier
gb  gigabyte multiplier
tb  terabyte multiplier
pb  petabyte multiplier


来源:https://stackoverflow.com/questions/24474017/what-is-the-full-list-of-number-suffixes-in-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!