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 8782465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:33:57+00:00 2026-06-13T20:33:57+00:00

I just just had a phone interview and they asked me this question: What

  • 0

I just just had a phone interview and they asked me this question:

“What is the size of an integer, and, what is the equation to work this out?”

I had no idea (Ok, I’m a bit stupid) but it just intrigues me to find out the answer. My person guess was count up in base 2.. But I dunno.

Anyone have any ideas?

  • 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-06-13T20:33:59+00:00Added an answer on June 13, 2026 at 8:33 pm

    It seems like the question was asked to make you ask them:

    • What is the largest value that you want the integer type to encode?

    Let’s assume they said we want MAX_VALUE to be the maximum value an integer type can have.

    This brings us to the equation. Since we are encoding it using bits we need log_2(MAX_VALUE) bits to encode any positive value of size up to MAX_VALUE. The logarithm of base 2 is there because with a bit pattern of size n you can encode up to 2^n different values. So if you want to know how long your maximum bit pattern needs to be to encode MAX_VALUE you need to calculate the log since:

    2^(log_2(MAX_VALUE)) = MAX_VALUE
    

    Now this is okay, unless you also want to encode the number 0. If you want to encode 0 as well then there are MAX_VALUE+1 numbers between 0 and MAX_VALUE so you need log_2(MAX_VALUE+1) bits to encode them all.

    Another important question is what is the MIN_VALUE that we want to encode?

    So in total you have MAX_VALUE + 1 + abs(MIN_VALUE) different values, so you will need :

    bits_needed = log_2(MAX_VALUE + 1 + abs(MIN_VALUE))
    

    As others have mentioned, in java int has max_value = 2,147,483,647 and min_value = -2,147,483,648. When you do the calculation you get log_2(4294967296) which is equal to 32. So 32 bits is the size of the integer type in java.

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

Sidebar

Related Questions

I just had a quick phone interview. The interviewer asked me a few questions
Just had a phone interview with TripAdvisor (and didn't make the cut). I was
I had written a small utility app just for my phone, which stopped the
Just had a discussion at work about the merits of using PostgreSQL over MySQL
just had a general question about how to approach a certain problem I'm facing.
I just had an idea, is that possible to protect my java sources (packed
I just had a quick question about git - how backwards compatible are git
I just had a question about aligning two expand-collapse boxes and got an answer
I had this idea and my first reaction after having it was That's a
Hello I just had a question about compatibility between the different versions of Android

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.