Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
Why BSON is not using uint32_t instead of int32_t for document lenght

According to BSON specification an int32_t is used for the total number of bytes comprising the document.

I can also see that mongo-c-driver is using Libbson and it's using int32_t.

But what is the reason to use signed integer instead of unsigned integer?

the document size will never be below 0. Can someone please explain the reason?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Document size is limited to 16 MB, which fits in a signed 32-bit integer with room to spare.

While document size limits larger than 16 MB were considered, my guess is there was no serious consideration of document sizes exceeding 2 GB, therefore the difference in range afforded by using unsigned 32-bit integers for length wasn't a meaningful benefit.

Thus, there is no reason to use an unsigned type.

Reasons to NOT use an unsigned type:

  • Wraparound potential from UINT_MAX to 0.
  • -1 could be used as a special designator.
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda