Go to Post As far as I am concerned, the quality of an electronic device is directly proportional to the number of blinky lights on it. - EricVanWyk [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Spotlight this post!  
Unread 29-04-2003, 22:07
srawls's Avatar
srawls srawls is offline
Registered User
#0122 (Nasa Knights)
 
Join Date: Dec 2001
Location: Yorktown
Posts: 507
srawls is an unknown quantity at this point
Send a message via AIM to srawls
Quote:
Originally posted by rbayer
As for the integer math, that only works assuming that bytevarX will never be bigger than the value you are testing for. If it could be, then the behavior is rather sporadic. For example. bitVarY=5/10 will assign the value 0 to bitVarY since the lowest-order bit of 5/10 (= 10b) is zero, wheras 5/15 (=11b) will assign it the value 1.
What about this:
Code:
bitVar = byteVAR / a MAX 1 'byteVar >= a
bitVar = a / (byteVAR MIN 1) MAX 1 'byteVar <= a
bitVar = (byteVAR / a) * (a / (byteVAR MIN 1) ) MAX 1 'byteVar == a (doesn't work for a=0)
Albeit, that fix makes it more bloated than helpful for the equality test. Here's an option I just thought of for an equality test (don't you just love bit fidling?)

Code:
bitVar = 0 ** (byteVAR - a) 'byteVar == a
If byteVAR == a, it will end up being 0^0, which is usually defined as one (although, I can't confirm the stamp will return 1). Otherwise, it will return 0. There is the case if byteVAR is less than a, then we have 0 ^ (- k), and that is a division by zero error (or maybe the stamp just returns 0?). You could fix that with a MIN statement though. I don't know how fast MIN and MAX statements are, so there is the highly likely chance that all this is futile, and Dr. Joe's way is much faster

Stephen
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
BS2 syntax (PBASIC) on the new controllers? Maybe! Jeremy_Mc Programming 0 25-10-2003 15:00
PBASIC Syntax Question Raven_Writer Programming 4 20-08-2003 08:07
Pbasic 2.5 syntax Rickertsen2 Programming 10 15-02-2003 08:56
Another PBASIC Question Ian W. Programming 4 31-01-2002 21:36
Simplifying PBasic IDiggles General Forum 16 06-11-2001 01:36


All times are GMT -5. The time now is 05:33.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi