Thread: on 16-bit system long will guarantee 4-bit integer type?

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    254

    on 16-bit system long will guarantee 4-bit integer type?

    Hi

    To cut the long story short. The books says int is system dependant, short takes 2 bytes and long takes 4 bytes and are system independent.

    First, could you please tell me what that 16-bit, 32-bit and 64-bit systems are? Please remember I'm a beginner and if you think the reply is going to fly over my head then you can simply tell me.

    Second, it says using long on 16-bit system such as MS-DOS will gurantee a four-bit integer. But long takes always four bytes and is system independent. There are only two bytes in 16 bits. Could you please shed some light on this if yu think I could understand this stuff?

    I offer my thanks for your help and time.

    Regards
    J
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jackson6612
    To cut the long story short. The books says int is system dependant, short takes 2 bytes and long takes 4 bytes and are system independent.
    Whatever books you are reading, they are wrong if they really state it as that. It is guaranteed that sizeof(short) <= sizeof(int) and sizeof(int) <= sizeof(long). Also, assuming an 8-bit byte, the minimum guaranteed ranges for short, int and long mean that sizeof(short) >= 2, sizeof(int) >= 2 and sizeof(long) >= 4.

    Quote Originally Posted by jackson6612
    First, could you please tell me what that 16-bit, 32-bit and 64-bit systems are? Please remember I'm a beginner and if you think the reply is going to fly over my head then you can simply tell me.
    Have you tried searching the Web? Explanations seem rather readily available online.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  4. All u wanted to know about data types&more
    By SAMSAM in forum Windows Programming
    Replies: 6
    Last Post: 03-11-2003, 03:22 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM