mersenneforum.org very long int
 Register FAQ Search Today's Posts Mark Forums Read

 2013-02-23, 02:02 #1 davar55     May 2004 New York City 5·7·112 Posts very long int 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.
2013-02-23, 02:21   #2
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts

Quote:
 Originally Posted by davar55 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.
http://en.wikipedia.org/wiki/Integer...ral_data_types shows it to be 64 bits

2013-02-23, 05:12   #3
Dubslow

"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts

Quote:
 Originally Posted by science_man_88 http://en.wikipedia.org/wiki/Integer...ral_data_types shows it to be 64 bits
Dear lord that is wrong -- the meaning of "long" varies from language to language, and in C their size is "implementation defined". So for me on GNU-Linux, an int is 32 bits while a long is 64, however on Windows (at least Visual Studio) an int and long are both 32 bits. Davar will simply have to experiment (or otherwise research) what size a long long is for him.

Code:
#include <stdio.h>

int main(void) {
printf("a long long has %d bytes\n", sizeof(long long int));
return 0;
}

 2013-02-23, 12:18 #4 davar55     May 2004 New York City 102138 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) { } and the compiler errs on the first line, same error.
 2013-02-23, 19:19 #5 Xyzzy     Aug 2002 100000011110112 Posts Code: #include #include 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; }
 2013-02-23, 19:52 #6 Dubslow Basketry That Evening!     "Bunslow the Bold" Jun 2011 40
 2013-02-23, 20:22 #7 ewmayer ∂2ω=0     Sep 2002 República de California 2·73·17 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.
 2013-02-23, 20:29 #8 Dubslow Basketry That Evening!     "Bunslow the Bold" Jun 2011 40
2013-02-23, 20:49   #9
chalsall
If I May

"Chris Halsall"
Sep 2002

132×59 Posts

Quote:
 Originally Posted by ewmayer 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.
As has been said many times before, both here and elsewhere...

"C -- All the power, and all the safety features, of a chain saw...."

2013-02-23, 20:59   #10
ewmayer
2ω=0

Sep 2002
República de California

2·73·17 Posts

Quote:
 Originally Posted by Dubslow 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]).
Which was of very great importance ... 30-40 years ago. Fortran-90 solved this in a more modern fashion via typedef foo_t = "get type of at least this size and precision" functionality.

Quote:
 tl;dr extreme portability.
I don't consider having to write custom header files and then deal with the inevitable bugs/crashes resulting from the inevitable hidden size assumptions which creep into one's code as an example of "portability". Allowing me to specify 'integer*4' and be guaranteed that I get just that (or at least that), in a highly visible type-size-encoding fashion ... that's portable.

I stand by my "appalling piece of stupidity" categorization. And it even stupider now than it was then.

 2013-02-23, 21:04 #11 Dubslow Basketry That Evening!     "Bunslow the Bold" Jun 2011 40

 Similar Threads Thread Thread Starter Forum Replies Last Post ThomRuley Msieve 3 2013-11-30 04:52 Zeta-Flux Soap Box 26 2011-10-19 00:51 grandpascorpion Programming 7 2009-10-04 12:13 panic Hardware 9 2009-09-11 05:11 schickel Lounge 2 2009-02-22 12:31

All times are UTC. The time now is 18:32.

Thu Oct 28 18:32:46 UTC 2021 up 97 days, 13:01, 0 users, load averages: 1.10, 1.25, 1.34