Article View: comp.bugs.misc
Article #8Re: Hummm, Altos compiler bug/feature?
From: richard.r.grady..jr
Date: Wed, 02 Aug 1989 16:05
Date: Wed, 02 Aug 1989 16:05
45 lines
1807 bytes
1807 bytes
In article <4874@macom1.UUCP> larry@macom1.UUCP (Larry Taborek) writes:
| Ok guys and gals.
|
| I have a Altos 586 computer running 3.1a version of Xenix. In
| using the standard compiler that comes with the development set,
| I found that I can only do mathmatical operations on shorts and
| integers. Floats, longs and doubles do not work. Example:
|
| main()
| {
| int a;
| long b;
|
| a=0;b=0;
| a++;
| printf("a = %d\n",a);
| a = a + 1;
| printf("a = %d\n",a);
| b++;
| printf("b = %d\n",b);
| b = b + 1;
| printf("b = %d\n",b);
| }
|
| When run returns:
|
| a = 1
| a = 2
| b = 0
| b = 0
|
| By the way, by using the sizeof command, I find that shorts and
| integers take 2 bytes, longs and floats take 4 bytes and doubles
| take 8 bytes.
In your example above, you have to tell printf()
that the data argument b is long.
You do this by putting a letter "l" in the format specification:
printf("b = %ld\n",b);
Otherwise, printf() expects a 2-byte quantity, and it takes the
first two (presumably, higher-order) bytes of the 4-byte long.
These 2 bytes would be 00H, and printf() outputs 0.
-------------------------------------------------------------------
Dick Grady r_r_grady@att.com ...!att!mvuxd!r4
Technical Details
Message-ID:
<8759@cbnews.ATT.COM>Path:
arc1-ca.pugleaf.net!utzoo!censor!geac!jtsv16!uunet!cs.utexas.edu!sun-barr!rutgers!bellcore!att!cbnews!r4References:
<4874@macom1.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!jtsv16!uunet!cs.utexas.edu!sun-barr!rutgers!bellcore!att!cbnews!r4 From: r4@cbnews.ATT.COM (richard.r.grady..jr) Newsgroups: comp.bugs.misc Subject: Re: Hummm, Altos compiler bug/feature? Keywords: cc, Altos, 586, Floating point Message-ID: <8759@cbnews.ATT.COM> Date: 2 Aug 89 16:05:31 GMT References: <4874@macom1.UUCP> Reply-To: r4@cbnews.ATT.COM (richard.r.grady..jr) Distribution: usa Organization: AT&T Bell Laboratories Lines: 45