![]() |
![]() |
#1 |
May 2004
New York City
5×7×112 Posts |
![]()
I noted recently in the forum someone referred to
the integer type "long long". Does this refer to an integer type with 64 bits? Or perhaps 128? I doubt that my c5.5.1 compiler supports it, and my test trial failed to get past the declaration. I once thought the adverbal phrase "very long" would be used to get a 64 bit type, and "very very long" 128. Same basic idea. I'd love to get a 64 bit integer from my compiler, to match the w8 x64 hw. |
![]() |
![]() |
![]() |
#2 | |
"Forget I exist"
Jul 2009
Dartmouth NS
2×52×132 Posts |
![]() Quote:
|
|
![]() |
![]() |
![]() |
#3 | |
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3·29·83 Posts |
![]() Quote:
Code:
#include <stdio.h> int main(void) { printf("a long long has %d bytes\n", sizeof(long long int)); return 0; } |
|
![]() |
![]() |
![]() |
#4 |
May 2004
New York City
5×7×112 Posts |
![]()
Thanks. I can't compile that code, it gives the "error"
"Too many types in declaration." The Borland c5.5.1 is an older compiler and I'm not sure whether it can generate 64 bit object code Perhaps using an argument flag I haven't tried yet. I earlier tried: Code:
long long x; void main(void) { } |
![]() |
![]() |
![]() |
#5 |
Aug 2002
22·2,161 Posts |
![]() Code:
#include <stdio.h> #include <limits.h> int main() { printf("Size of Char %d\n", CHAR_BIT); printf("Size of Char Max %d\n", CHAR_MAX); printf("Size of Char Min %d\n", CHAR_MIN); printf("Size of int min %d\n", INT_MIN); printf("Size of int max %d\n", INT_MAX); printf("Size of long min %ld\n", LONG_MIN); printf("Size of long max %ld\n", LONG_MAX); printf("Size of short min %d\n", SHRT_MIN); printf("Size of short max %d\n", SHRT_MAX); printf("Size of unsigned char %u\n", UCHAR_MAX); printf("Size of unsigned long %lu\n", ULONG_MAX); printf("Size of unsigned int %u\n", UINT_MAX); printf("Size of unsigned short %u\n", USHRT_MAX); return 0; } |
![]() |
![]() |
![]() |
#7 |
∂2ω=0
Sep 2002
República de California
267548 Posts |
![]()
When I was first learning C I found the lack of unambiguous data typing (analogous to Fortran-style 'integer*4') to be an appalling piece of stupidity. Since we are still stuck with it, I can only surmise that the folks that populate the C-related standards boards secretly enjoy such arcana.
Solution now is just as then: put together a header file containing the needed typedefs for the various platforms of interest to you, such that your code using said typedefs only shows the resulting unambiguous type, e.g. uint64. Write a small "on program start" test utility which checks the lengths and any other key type attributes (e.g. floating point ranges) at runtime. |
![]() |
![]() |
![]() |
#8 |
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3·29·83 Posts |
![]()
I read that the ill defined sizes were so that if you, say, wanted to write a C compiler on some something with like a few kilobytes of memory total, you (the implementation creator) could implement the types to be smaller than usual, right at the lower limit of the possible size range so that you would have to rewrite existing code (i.e. change to smaller types) as little as possible (any code that runs on such a device probably wouldn't rely on an int being 32 bits, since that's an unusual requirement [this forum being an exception]).
tl;dr extreme portability. |
![]() |
![]() |
![]() |
#9 | |
If I May
"Chris Halsall"
Sep 2002
Barbados
3·3,767 Posts |
![]() Quote:
"C -- All the power, and all the safety features, of a chain saw...." |
|
![]() |
![]() |
![]() |
#10 | ||
∂2ω=0
Sep 2002
República de California
22·2,939 Posts |
![]() Quote:
Quote:
I stand by my "appalling piece of stupidity" categorization. And it even stupider now than it was then. |
||
![]() |
![]() |
![]() |
#11 |
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3×29×83 Posts |
![]()
I agree it's quite dumb for a modern language. I was just trying to lend some perspective. (Keep in mind these choices were made in the 80s, and have been kept for backwards compatibility.)
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How long is too long? | ThomRuley | Msieve | 3 | 2013-11-30 04:52 |
How long until annihilation? | Zeta-Flux | Soap Box | 26 | 2011-10-19 00:51 |
Using long long's in Mingw with 32-bit Windows XP | grandpascorpion | Programming | 7 | 2009-10-04 12:13 |
I think it's gonna be a long, long time | panic | Hardware | 9 | 2009-09-11 05:11 |
How long is too long? | schickel | Lounge | 2 | 2009-02-22 12:31 |