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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:51:43+00:00 2026-05-30T23:51:43+00:00

I need to represent a 40-bit binary number. Which C datatype should be used

  • 0

I need to represent a 40-bit binary number. Which C datatype should be used to handle this?

  • 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-30T23:51:44+00:00Added an answer on May 30, 2026 at 11:51 pm

    If you’re using a C99 or C11 compliant compiler, then use int_least64_t for maximum compatibility. Or, if you want an unsigned type, uint_least64_t. These are both defined in <stdint.h>

    <stdint.h> usually also defines int64_t, but since it’s not required by the standard, it may not be defined in every implementation. However:

    • int_least64_t – at least 64 bits, and
    • int_fast64_t – the fastest size in this implementation of at least 64 bits

    are both required to be present in C99 and C11 (See § 7.18.1.2-3 in the C99 standard, and § 7.20.1.2-3 in the C11 standard).


    Although C99 specifies that long long is at least 64 bits on a particular machine (§ 5.2.4.2.1), the types in <stdint.h> are designed to be explicitly portable.

    You can read more about integer sizes on different platforms here.
    Note that the size of integer types are a problem with the long data type – on 64 bit Windows, it’s currently 32 bits, whereas on 64 bit linux it’s 64 bits. For this reason, I believe you’re safest using the types from <stdint.h>

    It’s worth noting that some feel that long long is more readable. Personally, I prefer the types from <stdint.h>, because they allow you to say what you mean when you use them – which I find more readable. Of course, readability is often a matter of taste – and if you’re working with an existing codebase, I’d just follow whatever they do 🙂


    If your compiler only supports C89, then R..’s solution will allow you up to 53 bits of integer precision.

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

Sidebar

Related Questions

I need to represent an IEEE 754-1985 double (64-bit) floating point number in a
We need to represent huge numbers in our application. We're doing this using integer
Given is an array of 320 elements (int16), which represent an audio signal (16-bit
Say I need a signal to represent numbers from 0 to 5; obviously this
I need to represent inheritance like Person/Student. How do you do that in LInqToSql?
I need to represent calculator key presses by the text for the keys to
I need to represent immutable vectors in Python (vectors as in linear algebra, not
I need a way to represent a 2-D array (a dense matrix) of doubles
I need to build a class that will represent a row in some table
I need a way for a single variable to represent two kinds of objects

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.