pete@tsc.dec.com (Pete Schmitt) (06/24/88)
When I run the following code on a VAX running Ultrix 2.2 I get a correct output of: 2 to the 4th = 16 When I run it on a 6300+ running V2.5 unix I get: 2 to the 0th = 4 Where is the problem? Is this a bug? The code: /* lpowd.c */ main() { long b,e,a,lpow(); b = 2; e = 4; a = lpow(b,e); printf("%d to the %dth = %d\n",b,e,a); } long lpow(lnum, n) long lnum; long n; { long p; p=1; for ( ; n > 0; --n) p *= lnum; return (p); }
mmengel@cuuxb.ATT.COM (~XT4103000~Marc Mengel~C25~G25~6184~) (06/27/88)
In article <547@tsc.dec.com> pete@tsc.dec.com (Pete Schmitt) writes: >When I run the following code on a VAX running Ultrix 2.2 I get a >correct output of: [example output deleted] >Where is the problem? Is this a bug? /* lpowd.c */ main() { long b,e,a,lpow(); b = 2; e = 4; a = lpow(b,e); printf("%d to the %dth = %d\n",b,e,a); *****************^SPLAT should be %ld for a long int, you are printing the low and high word of the 2, then the low word of the 4... } long lpow(lnum, n) long lnum; long n; { long p; p=1; for ( ; n > 0; --n) p *= lnum; return (p); } -- Marc Mengel attmail!mmengel {lll-crg|mtune|ihnp4}!cuuxb!mmengel