9

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.

Andrey Shchekin
  • 21,101
  • 19
  • 94
  • 162
  • Have you tried looking at the [PowerShell Language Specification](http://www.microsoft.com/en-us/download/details.aspx?id=36389)? – Richard Jun 29 '14 at 07:40
  • That should be all of them. – Joachim Isaksson Jun 29 '14 at 07:44
  • @Richard awesome, failed to find that for some reason. From spec it seems there are no other suffixes. Do you want to do an answer so that I accept it? Or I'll answer it myself. – Andrey Shchekin Jun 29 '14 at 07:44
  • @AndreyShchekin Now I'm not in quite such a rush... Also note `l` on a real makes it a decimal (like `d`) rather than long. – Richard Jun 29 '14 at 08:27
  • @Richard, can you clarify what you mean about `l` on a real please. If I do this: `(1.23L).GetType()`, I get `Int64`. – dan-gph Jun 30 '14 at 01:10
  • It's what the spec said: looks like it is an inconsistency between implementation and specification (only the language definers can determine where the error is). – Richard Jun 30 '14 at 06:41
  • 1
    Nice ASCII art table! (+1) – james.garriss Mar 20 '15 at 17:40

2 Answers2

8

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.

Richard
  • 106,783
  • 21
  • 203
  • 265
1

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
Maximilian Burszley
  • 18,243
  • 4
  • 34
  • 63
  • Any idea on how to find the available list on the current computer? Probably with some kind of class... [System.NumericLiterals] or something like that... – Luke Mar 17 '23 at 08:55