[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Modulus in Applesoft
- Subject: Re: Modulus in Applesoft
- From: mjmahon@aol.com (Michael J. Mahon)
- Date: 06 Oct 2004 07:26:24 GMT
- Newsgroups: comp.sys.apple2
- Organization: AOL http://www.aol.com
- References: <eYE8d.259383$%n4.21465@bignews6.bellsouth.net>
- Xref: g2news1.google.com comp.sys.apple2:4846
Jayson Smith wrote:
>I'm having problems using the Modulus operator under Applesoft, or don't
>know how to do it. In Integer, if I remember correctly, you could do, E.G.
>10 poke 493,x mod 256:poke 494,x/256
>and have a memory address poked in. That's just an example. However, doing
>print 900 mod 256
>in Applesoft produces the result 9000, and I think I just figured out why.
>I think it's printing the number 900, then the contents of variable 'mod'
>which is 0. So how do you do that in Applesoft?
There is no modulus function in Applesoft, though it would be handy.
It is usually done like this:
555 H = INT(V / 256): L = V - H * 256
This sets H to the high byte of V and L to the low byte.
The generalization to other divisors is straightforward.
-michael
Check out parallel computing for 8-bit Apples on my
Home page: http://members.aol.com/MJMahon/
- References:
- Modulus in Applesoft
- From: "Jayson Smith" <nospamratguyspambegone@nospamplease.bellsouth.ihatespam.net>