64 bit

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    64 bit

    C++ has no specify how many bytes is "int"

    Until now, in most of 32 bit processors, "int" has 4 bytes
    is it possible with new 64 bit processors (& compilers) "int" takes 8 bytes?

    thanks


  • John Harrison

    #2
    Re: 64 bit


    "<- Chameleon ->" <cham_gss@hotma il.NOSPAM.com> wrote in message
    news:bgagrm$3ri $1@nic.grnet.gr ...[color=blue]
    > C++ has no specify how many bytes is "int"
    >
    > Until now, in most of 32 bit processors, "int" has 4 bytes
    > is it possible with new 64 bit processors (& compilers) "int" takes 8[/color]
    bytes?[color=blue]
    >
    > thanks
    >[/color]

    Yes it is.

    There's no completely adequate solution to this problem in C++. I believe
    this is addressed by the C99 standard, ask on news:comp.lang. c if you are
    interested in this. Presumably one day the C99 standards will be applied to
    C++ as well.

    john


    Comment

    • Kevin Goodsell

      #3
      Re: 64 bit

      <- Chameleon -> wrote:
      [color=blue]
      > C++ has no specify how many bytes is "int"
      >
      > Until now, in most of 32 bit processors, "int" has 4 bytes
      > is it possible with new 64 bit processors (& compilers) "int" takes 8 bytes?
      >
      > thanks
      >
      >[/color]

      Basically the rules about the size of int are: It must be at least 16
      bits long, able to represent values from -32767 to 32767 (which implies
      the "at least 16 bits" rule), and there's a suggestion that it reflect
      the "natural word size of the target machine" or something like that.
      Also, it may not be longer than long or shorter than short.

      Note that int can be as little as 1 byte (without violating the rules
      above), meaning sizeof(int) == 1. "bytes" in C++ do not need to be 8
      bits long. A byte may be 32 bits long, for example (and I believe there
      are implementations where this is the case). On such an implementation
      you may have sizeof(char) == sizeof(short) == sizeof(int) ==
      sizeof(long) == 1.

      -Kevin

      Comment

      Working...