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

  • SEARCH
  • Home
  • 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 3938370
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:10:37+00:00 2026-05-20T00:10:37+00:00

I wonder if I could ask for some advice regarding some work I’m currently

  • 0

I wonder if I could ask for some advice regarding some work I’m currently doing.

I am working from a STANAG document which quotes the following:

ID numbers shall be formed as 4-byte numbers. The first (most significant) byte shall be the standard NATO country code for the object in question. Valid country codes shall range from 0 to 99 decimal… Country code 255 (hexadecimal FF) shall be reserved.

It then goes on to detail the three other bytes. In the specification, the ID is given the type Integer 4, where Integer n is a signed integer and n is 1,2, or 4 bytes.

My question, and I acknowledge this could be considered an ignorant question and I apologise, is that an integer is, as we know, 32 bits/4 bytes. How can “the first byte” be, for example, 99, when 99 is an integer?

I would greatly appreciate any clarification here.

  • 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-20T00:10:37+00:00Added an answer on May 20, 2026 at 12:10 am

    An integer is normally 4 bytes. But if you store a small number like 99, the other three bytes store 8x 0-value bits. The spec is asking for you to use one integer storage (4-bytes) to store 4 different smaller numbers within its bytes.

    The easiest way is probably to use a toInt function on an array of 4 bytes, e.g. (there is no byte[] length checking nor is this function tested – it is illustrative only)

    public static final int toInt(byte[] b) 
    {
        int l = 0;
        l |= b[0] & 0xFF;
        l <<= 8;
        l |= b[1] & 0xFF;
        l <<= 8;
        l |= b[2] & 0xFF;
        l <<= 8;
        l |= b[3] & 0xFF;
        return l;
    }
    
    byte[] bytes = new byte[] {99, 4, 9, 0};
    int i = toInt(bytes, 0);
    

    32-bits of an int

    11110101   00000100   00001001   00000000
    ^byte      ^byte      ^byte      ^byte
    

    Each block of 8 bits in the int is enough to “encode”/”store” a smaller number. So an int can be used to mash together 4 smaller numbers.

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

Sidebar

Related Questions

wonder if I could get some advice on the best way to solve this
I wonder if anyone could suggest the best way of looping through all the
I wonder if I could write a program in the C -programming language that
I wonder if you could share your thoughts / resources about live audio streaming
I wonder if someone could help me figure out how to parse a string
I wonder if you could help me with something I've been thinking about. Say
I wonder if someone could be kind enough to explain the function.prototype thingie (thingie!!??)
i wonder how i could store a xml structure in a persistence layer. cause
I wonder if anyone could help me with a problem I've been having. I
I wonder if you could automatically generate header header class functions automatically for a

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.