c++ - Integer casting in big-endian -
in big-endian machine, if have long
variable , cast char
, language specification guarantees least significant bits after cast?
in other words:
long = 50; char b = (char)a; assert(b == 50); /* true? */
i know true little-endian machines, big-endian?
...the value unchanged if can represented in destination type (and bit-field width); otherwise, value implementation-defined. (§4.7/3).
since char
must able accommodate values @ least 127, result in case must 50.
Comments
Post a Comment