Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4543456
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:32:03+00:00 2026-05-21T15:32:03+00:00

I am building PB messages containing 4 int32 fields. I wanted to add two

  • 0

I am building PB messages containing 4 int32 fields. I wanted to add two more boolean fields to this message. I noticed that the size increased by 4 bytes for 2 boolean fields. Do the booleans occupy as large as 2 bytes per field. Can’t they be stored in a more compact form ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:32:04+00:00Added an answer on May 21, 2026 at 3:32 pm

    Each field header takes 1 byte (for low field numbers; more for large field numbers), and each bool takes 1 byte. There is no sub-byte packing in protobuf; things are rounded up to the nearest byte.

    1 option would be to store an unsigned integer map – I.e. Treat each bool as a power of two and add them up (bitwise). Then you need one byte header and one byte data, so 2 bytes for both. You will, however, have to pack/unpack the integer yourself. Assuming you have a low field number, up to 7 bools is then 1 byte data plus 1 byte header. Since “varint” uses base-128 encoding (the msb is continuation), an 8th bool (up to 14 bools) would take 2 bytes data plus 1 byte header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a website with text box containing log messages. the log is getting
To clarify: I'm building a Logger class that allows me to easily log messages:
I'm currently building a user control that displays a message when a Repeater is
I'm building a application that sends a test message to another email, the program
I'm building a chatroom that sends messages via AJAX. Whenever I hit enter ,
I'm building an MVC web application that supports different types of messages between users.
I'm building an application that opens existing mail messages in Outlook. The user may
I am building a website that has a system where users can send messages
Lately I've been working on building two tools using Eclipse. I'm printing some messages
I am currently building two windows services: The first takes messages from an internet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.