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/
My Applesoft is rusty, but a MOD such as x = a mod b can be done as:
x = a - int( a / b )* b
Ben
As mentioned already Applesoft BASIC didn't have a modulus operator, but
the older Integer BASIC did have MOD. It also used # for 'not equal to'
instead of <>, which while it made no real difference to programming I
always though just looked nicer :o)
--
Roger Johnstone, Invercargill, New Zealand
http://vintageware.orcon.net.nz/
________________________________________________________________________
No Silicon Heaven? Preposterous! Where would all the calculators go?
Kryten, from the Red Dwarf episode "The Last Day"
In <eYE8d.259383$%n4.2...@bignews6.bellsouth.net> Jayson Smith wrote:
I always used something like this to find x mod y:
abs(x)-int(abs(x)/y)*y
If you know x will always be non-negative, you can leave out the two
occurrences of abs() and speed things up a bit.
_/_
/ v \ Scott Alfter (remove the obvious to send mail)
(IIGS( http://alfter.us/ Top-posting!
\_^_/ rm -rf /bin/laden >What's the most annoying thing on Usenet?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Linux)
iD8DBQFBZtJ2VgTKos01OwkRAtQhAJ91lukSMekfBDUTUfotYQ6ihtld4gCgsyTh
s5LyglT8AdUv0lclgfID/MI=
=0xj2
-----END PGP SIGNATURE-----