Literal for a short
-
We can put a
"u"
after a numeric literal to indicate that it should be compiled as an unsigned int. Or we can put"ll"
to indicate that it should be compiled as a long long. But what is the correct character to indicate that it should be compiled as a short?The difficult we do right away... ...the impossible takes slightly longer.
-
We can put a
"u"
after a numeric literal to indicate that it should be compiled as an unsigned int. Or we can put"ll"
to indicate that it should be compiled as a long long. But what is the correct character to indicate that it should be compiled as a short?The difficult we do right away... ...the impossible takes slightly longer.
There isn't one. You'd have to cast it:
short(0)
. EDIT: I prefer to useint16_t
oruint16_t
rather than assuming that's what I'll get. But if you're working with code that already usesshort
, go ahead and use it.Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing. -
There isn't one. You'd have to cast it:
short(0)
. EDIT: I prefer to useint16_t
oruint16_t
rather than assuming that's what I'll get. But if you're working with code that already usesshort
, go ahead and use it.Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.Thanks, Greg.
The difficult we do right away... ...the impossible takes slightly longer.