Re: [protobuf] Can I use int16 instead of int32 to verify a variable?

908 views
Skip to first unread message

Feng Xiao

unread,
May 7, 2013, 1:42:38 PM5/7/13
to 王海龙, Protocol Buffers
On Thu, Apr 25, 2013 at 9:36 PM, 王海龙 <hailong...@gmail.com> wrote:
Hi,
I have a question here,
I want use int16 (short) to verify a variable,because int32 is too big for me , I want to reduce the length of my package.
What do you mean by "the length of your package"? I believe using int16 doesn't save you any memory or decrease the wire format size.
 
Is there any way to do this?
Thank you !

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Marc Gravell

unread,
May 7, 2013, 2:41:15 PM5/7/13
to 王海龙, Protocol Buffers
On 7 May 2013 18:53, "Marc Gravell" <marc.g...@gmail.com> wrote:

Protobuf has a fee encodings for integer data, which basically come down to:

- varint (with or without zigzag)
- fixed-32 (always 4 bytes)
- fixed-64 (always 8 bytes)

For 16 bits, you will do best with varint. If the data can be negative (signed), ensure you are using the zigzag form (sint32). But that is all the options.

Marc

On 7 May 2013 18:36, "王海龙" <hailong...@gmail.com> wrote:
Hi,
I have a question here,
I want use int16 (short) to verify a variable,because int32 is too big for me , I want to reduce the length of my package.
Reply all
Reply to author
Forward
0 new messages