PowerShell中的数字后缀的完整列表是什么?

时间:2014-06-29 07:30:17

标签: powershell number-literal

您可以在PowerShell编号文字上使用的完整后缀列表是什么?
到目前为止,我发现:

╔════════╦═════════╦════════════════════════╗
║ 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 ║
╚════════╩═════════╩════════════════════════╝

但我找不到列出所有这些内容的来源。

2 个答案:

答案 0 :(得分:8)

根据完整集PowerShell Language Specification (V3)

  • §2.3.5.1.1整数文字包括:lkbmbgbtb,和pb
  • §2.3.5.1.2 Real Literals 添加d

据我所知(未发布规范更新)PowerShell V4不会添加任何其他后缀。

答案 1 :(得分:1)

足够了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