Google protocol buffers int32 vs int64

If I store the whole field in int32 ... will it use more space than int64? From what I understand, varint will adjust its size to the size of the stored number.

+4
source share
1 answer

No, this only affects the generated code. Any combination of [s|u]int{32|64} uses the encoding "varint", so the size is usually related to the value, at least after the difference in negative numbers is noted. In particular, a negative number that does not use uses sint* will be disproportionately large (10 bytes, IIRC), regardless of 32 or 64.

+4
source

Source: https://habr.com/ru/post/1394845/


All Articles