Monday, July 27, 2009

Basic data types in C: int, float, char, double, string...limitations and different values???

basic data types in C: int, float, char, double, string...limitations and different values???

Basic data types in C: int, float, char, double, string...limitations and different values???
You can find the types and limits youself, by checking the files thay come with your compiler. There should be a header file 'limits.h', or 'climits.h' if you have a c++ compiler. In mine, this is linked to a '_lim.h' header file. The file is in the 'include' directory / folder. In this file, you will find definitions like this:





#define CHAR_BIT 8 /* number of bits in a char */


#define MB_LEN_MAX 2 /* max. # bytes in multibyte char */





#define SCHAR_MIN (-128) /* minimum signed char value */


#define SCHAR_MAX 127 /* maximum signed char value */


#define UCHAR_MAX 255 /* maximum unsigned char value */





#if ('\x80' %26lt; 0)


#define CHAR_MIN SCHAR_MIN /* minimum char value */


#define CHAR_MAX SCHAR_MAX /* maximum char value */


#else


#define CHAR_MIN 0


#define CHAR_MAX UCHAR_MAX


#endif





#define SHRT_MIN (-32767-1) /* minimum signed short value */


#define SHRT_MAX 32767 /* maximum signed short value */


#define USHRT_MAX 65535U /* maximum unsigned short value */





#define LONG_MIN (-2147483647L-1) /* minimum signed long value */


#define LONG_MAX 2147483647L /* maximum signed long value */


#define ULONG_MAX 4294967295UL /* maximum unsigned long value */





#if defined (_INTEGRAL_MAX_BITS) %26amp;%26amp; (_INTEGRAL_MAX_BITS %26gt;= 64)


#define _I64_MIN (-9223372036854775807i64-1) /* minimum signed __int64 value */


#define _I64_MAX 9223372036854775807i64 /* maximum signed __int64 value */


#define _UI64_MAX 18446744073709551615ui64 /* maximum unsigned __int64 value */


#endif





#define INT_MIN LONG_MIN /* minimum signed int value */


#define INT_MAX LONG_MAX /* maximum signed int value */


#define UINT_MAX ULONG_MAX /* maximum unsigned int value */





Basically all values are for 32 bit machines, except the one with 64 explicity in the name. These ones are for 64 bit machines. The values may be different on your machine, so have a look for the(se) header file(s).
Reply:Try this,





http://www.informit.com/articles/article...





Have fun but be safe!
Reply:string is not a data type in C only int, char, float,double,long are the datatypes.


where as int isfor integer values only that too upto -32867(number i can't remember exactly)to +32868.(8 bits)


char is a single character


float is for decimal numbers (8 bits and decimal values)


long is for big integer values(more than 8 bits)


double is for floating point values of large size
Reply:Because you didn't really ask a question, I can only guess that some of this will be useful to you:





http://www.google.co.uk/search?hl=en%26amp;sa=...





Rawlyn.

artificial flowers

No comments:

Post a Comment