Data Types

why does c/c++ have so many data types? i.e. int32, int64, long, float, double.... Shouldn't there just be only the necessary datatypes?

Comments

  • : why does c/c++ have so many data types? i.e. int32, int64, long, float, double.... Shouldn't there just be only the necessary datatypes?
    :

    they are all necessary, depending on the program. They are all necessary at one time or another because they each do something different.
  • [b][red]This message was edited by MT2002 at 2005-8-24 20:5:38[/red][/b][hr]
    : : why does c/c++ have so many data types? i.e. int32, int64, long, float, double.... Shouldn't there just be only the necessary datatypes?
    : :
    :
    : they are all necessary, depending on the program. They are all necessary at one time or another because they each do something different.
    :
    [blue]
    Actually, "int32" and "int64" are [b]not[/b] defined
    by C/C++. They are defined by either the compiler or
    *.lib file. Im assuming they are used for portability
    (ie; "int32" is a 4 byte int, "int64" 5 byte).

    The only data types are char,int,float,double, and void.

    "signed","unsigned" are used to tell the
    compiler how to represent the data.

    "short", "long" I *think* are used for data type sizes??
    I forget--I never had a use for them!
    [/blue]

  • : [b][red]This message was edited by MT2002 at 2005-8-24 20:5:38[/red][/b][hr]
    : : : why does c/c++ have so many data types? i.e. int32, int64, long, float, double.... Shouldn't there just be only the necessary datatypes?
    : : :
    : :
    : : they are all necessary, depending on the program. They are all necessary at one time or another because they each do something different.
    : :
    : [blue]
    : Actually, "int32" and "int64" are [b]not[/b] defined
    : by C/C++. They are defined by either the compiler or
    : *.lib file. Im assuming they are used for portability
    : (ie; "int32" is a 4 byte int, "int64" 5 byte).
    :
    : The only data types are char,int,float,double, and void.
    :
    : "signed","unsigned" are used to tell the
    : compiler how to represent the data.
    :
    : "short", "long" I *think* are used for data type sizes??
    : I forget--I never had a use for them!
    : [/blue]
    :
    :

    int64 would be an 8 byte int (assuming 8-bit bytes)
    short would be int16 (2-byte int)
    long would be int32 (4-byte int)


    [italic][blue]To understand recursive, first you need to understand recursive[/blue][/italic]

  • : int64 would be an 8 byte int (assuming 8-bit bytes)
    : short would be int16 (2-byte int)
    : long would be int32 (4-byte int)

    [purple]...and the type [blue]int[/blue] is either [blue]short[/blue] or [blue]long[/blue], depending on the compiler. in VC++, [blue]long[/blue] and [blue]int[/blue] are same while in TC++ [blue]short[/blue] and [blue]int[/blue] are same.[/purple]
  • : why does c/c++ have so many data types? i.e. int32, int64, long, float, double.... Shouldn't there just be only the necessary datatypes?
    :
    I think this question is invalid that why C++ has so many data types.All this datatypes are necessary and they are needed in different types of application.
    Thanks.
  • : [blue]
    : "short", "long" I *think* are used for data type sizes??
    : I forget--I never had a use for them!
    : [/blue]
    :

    Just wait until you have to program something embedded or something with limited memory... Then you'll be using them a lot and wonder how you ever got along without using them... Of course PC memory is cheap, so most of the time you don't have to worry about it...

  • : why does c/c++ have so many data types? i.e. int32, int64, long, float, double.... Shouldn't there just be only the necessary datatypes?
    :

    I do work with a proprietary language (Galil) that has but one data type from the programmers point of view, but that language is designed for a highly specific task (motion control). If you want to manipulate strings in this language you are out of luck. Same with data structures - does not support them.

    For a general purpose language like C, it becomes important for the programmer to control both the size, and the way, in which data is stored/represented in memory. There are a number of reasons, but the bottom line (IMO) is that these different data types allow for more efficient and compact code to be written.
  • [b][red]This message was edited by MT2002 at 2005-8-25 16:9:16[/red][/b][hr]
    : : int64 would be an 8 byte int (assuming 8-bit bytes)
    : : short would be int16 (2-byte int)
    : : long would be int32 (4-byte int)
    :
    : [purple]...and the type [blue]int[/blue] is either [blue]short[/blue] or [blue]long[/blue], depending on the compiler. in VC++, [blue]long[/blue] and [blue]int[/blue] are same while in TC++ [blue]short[/blue] and [blue]int[/blue] are same.[/purple]

    [blue]
    Your right..When I said "int64=5 bytes" I was thinking
    in terms of base-2 multiply! ie; 1,2,4,8,16,24,32,[b]64[/b]..
    Dont know what I was thinking! :-)

    @OP:
    As others suggested, all data types has specific uses
    depending on the app/OS/and compiler. Does anyone
    remember [b]far[/b] and [b]near[/b]?
    [/blue]

  • : : [blue]
    : : "short", "long" I *think* are used for data type sizes??
    : : I forget--I never had a use for them!
    : : [/blue]
    : :
    :
    : Just wait until you have to program something embedded or something with limited memory... Then you'll be using them a lot and wonder how you ever got along without using them... Of course PC memory is cheap, so most of the time you don't have to worry about it...
    :
    [blue]
    Luckey for me, all I worked with was PCs :-).[/blue]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories