Ranges of data other than operating systems

8-bit, 16-bit, 32-bit, 64-bit operating systems have different data ranges for integers, float and double.

Is it a compiler or processor that makes a difference (8 bits, 16 bits, 32 bits, 64 bits).

If on the network, if 16-bit integer data from one system is transferred to a 32-bit system or vice versa, the data will be correctly represented in memory. Please help me understand.

+5
source share
5 answers

Ultimately, it depends on the compiler. The compiler can choose any type of data that he likes * even if he must simulate his behavior using software routines. Of course, as a rule, in order to increase efficiency, he will try to replicate his own types of basic equipment.

As for your second question, yes, of course, if you transfer the original representation from one architecture to another, it may not be interpreted correctly (concretization is another problem). This is why type functions are used ntohs().

* Well, literally nothing he likes. The C standard sets some restrictions, such as intto be at least equal short.

+7

( "" ) C. , C , , ; , ( , Java, ) , .

+3

. ( , ).

, . uint64_t, uint32_t int, short ..

- , ( BigEndian LittleEndian)

+2

.

int , stdint.h header [wikipedia], int8_t, int16_t, int32_t, int64_t, .

.

+1

, . endian.

If it had not been a problem with the API-interfaces, the compiler can be freely set its short, int, longin its sole discretion. Bot often, API calls are associated with these types. For instance. the function open()returns the intsize of which must be correct.

But types can also be part of the definition of ABI.

+1
source

All Articles