BreezyMain
BreezyMain

Reputation: 163

Why string.pack pack integer with 4 bytes?

As we all known, in standard Lua 5.4, a integer has 64 bits (8 bytes).

But string.packsize('i') == 4, that is to say a integer will be pack into 4 * 8 = 32 bits. It's strange, isn't it?

Upvotes: 1

Views: 1100

Answers (1)

BreezyMain
BreezyMain

Reputation: 163

Sorry for noise, it's because the "int" here refering is a native-sized int, as reference mentioned.

And in the standard C, the size of int is 32 bits (4 bytes).

Upvotes: 1

Related Questions