I am wonder why int32 field (with negative value) has 10 bytes?
10 - field No 2, wire type 0
FD FF FF FF FF FF FF FF FF 01 - field value = -3
Can someone explain it to me?
--
You received this message because you are subscribed to the Google Groups
Protocol Buffers group.
To post to this
... for a negative number, the resulting varint is *always ten bytes long
...*
I didn't saw that part.
Thanx
2010/3/21 Evan Jones ev...@mit.edu
On Mar 21, 2010, at 8:46 , adamdms wrote:
I am wonder why int32 field (with negative value) has 10 bytes?
10 - field No 2, wire type 0
FD FF FF FF
On Sun, Mar 21, 2010 at 08:05, Adam Kwintkiewicz
adam.kwintkiew...@gmail.com wrote:
... for a negative number, the resulting varint is always ten bytes long
...
Reason for that is the varint encoding: it only encodes the bits that
are set in an integer. For small positive values that results in
Thank you for your reply. Yes you are right. I just wondered why int32
consists of 10 bits, rather than a maximum of 5 (in the case of large or
negative numbers).
Adam
2010/3/21 Henner Zeller henner.zel...@googlemail.com
On Sun, Mar 21, 2010 at 08:05, Adam Kwintkiewicz
On Sun, Mar 21, 2010 at 8:54 AM, Adam Kwintkiewicz
adam.kwintkiew...@gmail.com wrote:
Thank you for your reply. Yes you are right. I just wondered why int32
consists of 10 bits, rather than a maximum of 5 (in the case of large or
negative numbers).
So that you can change an int32 to int64