C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28691
Number of posts: 94711

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Data Types Posted by Danty on 24 Aug 2005 at 5:53 PM
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?
Report
Re: Data Types Posted by stober on 24 Aug 2005 at 7:29 PM
: 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.
Report
Re: Data Types Posted by MT2002 on 24 Aug 2005 at 8:03 PM
This message was edited by MT2002 at 2005-8-24 20:5:38

: : 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.
:

Actually, "int32" and "int64" are not 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!


Report
Re: Data Types Posted by DB1 on 24 Aug 2005 at 8:57 PM
: This message was edited by MT2002 at 2005-8-24 20:5:38

: : : 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.
: :
:
: Actually, "int32" and "int64" are not 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!
:

:
:

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)


To understand recursive, first you need to understand recursive

Report
Re: Data Types Posted by Donotalo on 24 Aug 2005 at 9:38 PM
: 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)

...and the type int is either short or long, depending on the compiler. in VC++, long and int are same while in TC++ short and int are same.
Report
Re: Data Types Posted by MT2002 on 25 Aug 2005 at 4:06 PM
This message was edited by MT2002 at 2005-8-25 16:9:16

: : 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)
:
: ...and the type int is either short or long, depending on the compiler. in VC++, long and int are same while in TC++ short and int are same.


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,64..
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 far and near?


Report
Re: Data Types Posted by istrasci on 25 Aug 2005 at 8:36 AM
:
: "short", "long" I *think* are used for data type sizes??
: I forget--I never had a use for them!
:

:

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...

Report
Re: Data Types Posted by MT2002 on 25 Aug 2005 at 4:13 PM
: :
: : "short", "long" I *think* are used for data type sizes??
: : I forget--I never had a use for them!
: :

: :
:
: 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...
:

Luckey for me, all I worked with was PCs .

Report
Re: Data Types Posted by omer041 on 24 Aug 2005 at 10:48 PM
: 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.
Report
Re: Data Types Posted by dennisparker on 25 Aug 2005 at 12:02 PM
: 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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.