Numeric primitives and their suffixes

I can only speculate, but note that since a-f are valid hexadecimal values, they can't be used for suffixes for integral types. That's probably the reason that bYte and deciMal get the slightly less mnemonic abbreviations. Likewise, note that there are separate (very rarely used) suffices for using hexadecimal notation with floats: LF for floats and lf for float32s.

By these rules, all of the following are valid literals:

0xb  // int, in hex
0xby // byte, in hex
0xabcdef // int, in hex
0xabcdeflf // float32, in hex

I think @kvb made a really good speculation. Here are two minor additions:

  • There is one minor issue in your table, f is a suffix used for float32 (also called single corresponding to System.Single) while floating point without suffix becomes F# float (corresponding to System.Double). The naming of floats is really confused in F#, so I don't think this has any special logic (just a need to distinguish between two kinds of floats).

  • Your table also does not include l (which is used for int). This means that int16, int32 and int64 have suffixes s, l and L respectively (which probably means, "short", "long" and "long long" in the C terminology).

  • I like to read the M suffix in decimals as "money", because decimal is most often used to represent money (because of its high precision). I'm not sure if this is the reason why the prefix is M, but it is easy to remember :-).

Tags:

F#