Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!mucs!logitek!grep!frank From: frank@grep.co.uk (Frank Wales) Newsgroups: comp.sys.handhelds Subject: Re: 32 Bt Mant is < I need! Message-ID: <1990Dec10.212231.10744@grep.co.uk> Date: 10 Dec 90 21:22:31 GMT References: <276057f4:1381comp.sys.handhelds@hpcvbbs.UUCP> Reply-To: frank@grep.co.uk (Frank Wales) Organization: Grep Limited, LEEDS, UK Lines: 44 In article <276057f4:1381comp.sys.handhelds@hpcvbbs.UUCP> akcs.scotty@hpcvbbs.UUCP (SCOTTY THOMPSON) writes: >I need help. Using binary numbers on my 48SX and trying to raise 2 >to the nth power to test a flag has become a difficult and unneccessary >chore. There are more direct ways to diddle bits in binary numbers; off the top of my head, one way is to use the flag operations(*). For example: << RCLF DUP 1 GET 4 ROLL 2 ->LIST STOF SWAP FS? SWAP STOF >> with the binary number to be tested in level two and the bit to test (1..64) in level one returns 0 or 1 as appropriate. Adjust for bits in 0..63 if desired. Being able to set or clear the bits comes free; you could perform several tests or manipulations while the value is in the flags, if that's appropriate to what you're doing. Note that this code scribbles on your User flags if interrupted (by, say, ATTN) or given defective arguments. A more elaborate version could be concocted to avoid these problems by using IFERR, if necessary. Note also that it could be rewritten shorter if use were made of the system flags, as in: << RCLF ROT STOF SWAP NEG FS? SWAP STOF >> but having the system in an arbitrary state might be confusing if this version is elaborated. [(*) Since I've only thought about this for two minutes, no doubt there is a better way. However, using the PICT-based graphics operations to do the bit manipulations is left as an exercise in creative craziness.] >When I have large binary numbers and I want to test a bit in that number >using the binary AND command, from within a loop or controled from a >variable (so I can't just have a big list and pick, enter and choose), >I can't get a number that big with floating point because the mantissa >is only 32 bits. There are large differences in errors. The mantissa isn't 32 bits, it's twelve decimal digits. Since 2^39 is about 5.5e11, you could exponentiate up to 39 before losing precision. -- Frank Wales, Grep Limited, [frank@grep.co.uk<->uunet!grep!frank] Kirkfields Business Centre, Kirk Lane, LEEDS, UK, LS19 7LX. (+44) 532 500303