🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by Larry Taborek Tue, 01 Aug 1989 21:06
Hummm, Altos compiler bug/feature?
#6
Author: Larry Taborek
Date: Tue, 01 Aug 1989 21:06
45 lines
1507 bytes
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.

I have looked in the compiler options to find out if there are
any floating point options.  There arn't, or at least none
documented.  Now I figure that you HAVE to be able to do this, so
what am I doing wrong?

Larry
-- 
Larry Taborek	..!uunet!grebyn!macom1!larry	Centel Federal Systems
		larry@macom1.UUCP		11400 Commerce Park Drive
						Reston, VA 22091-1506
						703-758-7000
Re: Hummm, Altos compiler bug/feature?
#8
Author: richard.r.grady..jr
Date: Wed, 02 Aug 1989 16:05
45 lines
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 
Re: Hummm, Altos compiler bug/feature?
#9
Author: Brandon S. Allbery
Date: Sun, 06 Aug 1989 22:46
8 lines
965 bytes
You're gonna have one heck of a hard time trying to get a fix for that....

++Brandon
-- 
Brandon S. Allbery, moderator of comp.sources.misc	     allbery@NCoast.ORG
uunet!hal.cwru.edu!ncoast!allbery		    ncoast!allbery@hal.cwru.edu
"Why do trans-atlantic transfers take so long?"
"Electrons don't swim very fast."  -john@minster.york.ac.uk and whh@PacBell.COM
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads