Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numeric primitives and their suffixes

Tags:

f#

I'm trying to figure out what's the real meaning behind these suffixes. In other words I'm trying to "translate" them.

+----+--------------+--------+
|    |     Type     | Suffix |
+----+--------------+--------+
|  1 | byte         | uy     |
|  2 | sbyte        | y      |
|  3 | int16        | s      |
|  4 | uint16       | us     |
|  5 | int, int32   |        |
|  6 | uint, uint32 | u      |
|  7 | int64        | L      |
|  8 | uint64       | UL     |
|  9 | float        |        |
| 10 | float32      | f      | (edited, thanks Thomas)
| 11 | decimal      | M      |
+----+--------------+--------+

E.g. I assume that "f" stands for f loat. But for what does e.g. "M" stand for. Why isn't "d" used for d ecimal ? For what does "uy" stand for? And so forth ...

Can anyone "translate" this ?

like image 829
Miro Avatar asked Feb 07 '13 19:02

Miro


1 Answers

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
like image 187
kvb Avatar answered Sep 22 '22 00:09

kvb