printf/scanf format character(s) for 64 bit ints ?? 
Author Message
 printf/scanf format character(s) for 64 bit ints ??

We are adding a 64 bit integer type to our C compiler. If your C compiler
andles 64-bit integers, what do you put in the format string for scanf/printf
to read and print them?

I don't have manuals for other systems readily available. I know that
Convex uses %ll, but I would prefer a single letter: maybe %L.

Please let me hear your facts and/or opinions.


AT&T GIS Dept. 789                 ...!uunet!ncrcom!ncrcae!grok162!marv
3325 Platt Springs Rd.       phone: 1 803 939 5501
W. Columbia, SC 29170-2203     fax: 1 803 939 7317
--

AT&T GIS Dept. 789                 ...!uunet!ncrcom!ncrcae!grok162!marv
3325 Platt Springs Rd.       phone: 1 803 939 5501
W. Columbia, SC 29170-2203     fax: 1 803 939 7317



Mon, 19 Aug 1996 04:50:13 GMT  
 printf/scanf format character(s) for 64 bit ints ??

Quote:
>We are adding a 64 bit integer type to our C compiler. If your C compiler
>andles 64-bit integers, what do you put in the format string for scanf/printf
>to read and print them?
>I don't have manuals for other systems readily available. I know that
>Convex uses %ll, but I would prefer a single letter: maybe %L.

  From ISO C 7.13 (Future library directions) -
  7.13.6 Input/output <stdio.h> : "Lowercase letters may be added to the
conversion specifiers in fprintf and fscanf.  Other characters  may be used
as extensions."  It looks as if the committee wanted to reserve the lowercase
letters for extra conversion specifications to be put in future revisions.
So, for current implementations, uppercase letters and _ might be a better
choice.

-------
/* Ajoy Krishnan T,
   Senior S/W Engineer, Hughes Software Systems,
   New Delhi - 19, India.



Mon, 26 Aug 1996 12:04:00 GMT  
 printf/scanf format character(s) for 64 bit ints ??

Quote:
>We are adding a 64 bit integer type to our C compiler. If your C compiler
>andles 64-bit integers, what do you put in the format string for scanf/printf
>to read and print them?

"%l" on the DEC Alpha cc.
Quote:

>I don't have manuals for other systems readily available. I know that
>Convex uses %ll, but I would prefer a single letter: maybe %L.

>Please let me hear your facts and/or opinions.

Make the 64 bit integer type "long" and you don't have to invent
anything.

Just my $0.02,
Dan
--
Dan Pop
CERN, CN Division

Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



Mon, 26 Aug 1996 17:49:02 GMT  
 printf/scanf format character(s) for 64 bit ints ??

: Make the 64 bit integer type "long" and you don't have to invent
: anything.

        That wuld create porability problems, then everyone else that
wanted to use any of the source for that compiler would have to have
a double long (in most cases) to accomodate for the 64 bits.  The same
thing can occure when going from UNIX to DOS, and int just isn't the
same thing anymore,  if you are lucky there will be the ocasional
programmer that will take this into account and instead of just saying
'int i', will say 'long int i', this dosen't mean much for the unix
os but for the dos os it means a world of difference, just like going
the other way 'short int i' can be a great deal of help (ie dos to unix).
Though I'll grant you this the 16 bit int and 32 bit int (almost) are
becoming a dieing breed they don't need to be totally ignored.  I can't
recommend a format specifier for the original poster since I don't run
into the need for such a thing just take into consideration that C code
goes between platforms all the time.

-------------------------------------------------------------------------

                Student programmers have (*NULL) free time...
-------------------------------------------------------------------------



Tue, 27 Aug 1996 09:24:50 GMT  
 printf/scanf format character(s) for 64 bit ints ??

Quote:

>: Make the 64 bit integer type "long" and you don't have to invent
>: anything.

>    That wuld create porability problems, then everyone else that

Yes, if the code is not portable, this will certainly cause portability
problems :-)

Quote:
>wanted to use any of the source for that compiler would have to have
>a double long (in most cases) to accomodate for the 64 bits.  The same
>thing can occure when going from UNIX to DOS, and int just isn't the
>same thing anymore,  if you are lucky there will be the ocasional
>programmer that will take this into account and instead of just saying
>'int i', will say 'long int i', this dosen't mean much for the unix
>os but for the dos os it means a world of difference, just like going
>the other way 'short int i' can be a great deal of help (ie dos to unix).
>Though I'll grant you this the 16 bit int and 32 bit int (almost) are
>becoming a dieing breed they don't need to be totally ignored.  I can't
>recommend a format specifier for the original poster since I don't run
>into the need for such a thing just take into consideration that C code
>goes between platforms all the time.

C code which is not _broken_ goes between platforms all the time
without any problems, no matter what the sizes of the integer types
are. The standard specifies the minimum number of bits for each integer
type. If a program relies on a greater number of bits than the one
guaranteed, that program is non-portable and it can be considered
broken from the portability point of vue.

The idea to design compilers in such a way that non-portable code can
be ported doesn't make much sense for me. If a program is broken, you
don't fix the compiler, although the reverse happens from time to time
:-)

Dan
--
Dan Pop
CERN, CN Division

Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



Tue, 27 Aug 1996 16:48:09 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. 64 Bit * 64 Bit = 128 Bit

2. 64 bit ints and stdio

3. C compiler with 64-bit ints??

4. 64 bit ints

5. 64-bit ints, and printing them out.

6. 64-bit ints

7. printf value of 64-bit int

8. 64 bit a.out format

9. Help: porting 32-bit app to 64-bit Dec Alpha

10. 64-bit integer on a 32-bit machine

11. Calling 64 bit lib. from 32 bit program

12. emulating a 64 bit divide with 2 32 bit registers in ansi c

 

 
Powered by phpBB® Forum Software