🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #15225

Re: LSC error in printf?

#15225
From: chris
Date: Mon, 23 Mar 1987 15:49
50 lines
2165 bytes
In article <306@umbc3.UMD.EDU>, scotty@umbc3.UMD.EDU (Scott Paisley) writes:
> 
> 	I was playing around with LSC 2.01 the other night and was
> having some fun with large integers.  Anyway the following program
> gives some interesting results...
> 
> #include <stdio.h>
> main()
> {
> 	long biggie = 0x7fffffff;
> 	printf("Biggie is 0x%x  0x%x\n", biggie, biggie);
> }
> 
.......chopped for brevity & reader's sake.........
> It appears that only half of the longword is getting printed with printf.
> (By doing successive printfs, we got the other half of the word - lord knows
>  why...)
> 
> What is going on here?  Is this a bug or undocumented feature?  :-)
> 
> -- 
> Scott Paisley	

Scotty,

At the bottom of page 51 in the manual update, you will find the solution
to your problem among many others.  To quote:

PROBLEM:  printf and scanf don't seem to work correctly with long or
          double data.

SOLUTION: 
   A common misconception about printf is that printf "knows" about its
arguements.  If you pass a long expression to printf, you must specify in
the format string that you want a long expression to be printed.  Example:

int anInt;
long aLong;
printf("long is %ld, int is %d\n", aLong, anInt);
___________________________

So there ya have it....put that lower-case "L" before the d.  I just
tried your program...in your case, it is acceptable to use the line:
printf("Biggie is 0x%lx\n", biggie);


-- 
ARPA   : chris@umbc3.UMD.EDU		BITNET : chris@umbc

"If all else fails, read the instructions!"
Technical Details
Message-ID: <307@umbc3.UMD.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!brl-adm!seismo!mimsy!cvl!umd5!umbc3!chris
References: <306@umbc3.UMD.EDU>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!brl-adm!seismo!mimsy!cvl!umd5!umbc3!chris
From: chris@umbc3.UUCP
Newsgroups: comp.sys.mac
Subject: Re: LSC error in printf?
Message-ID: <307@umbc3.UMD.EDU>
Date: Mon, 23-Mar-87 10:49:13 EST
Article-I.D.: umbc3.307
Posted: Mon Mar 23 10:49:13 1987
Date-Received: Thu, 26-Mar-87 03:56:07 EST
References: <306@umbc3.UMD.EDU>
Organization: Univ of Maryland Baltimore County
Lines: 49
Keywords: buggies!
Summary: The solution to your problems is in the manual updates...