The IMP logical operator converts the result of two comparative values and returns a bit result.I don't know what it is saying. "Different result". How is it different? I have no clue what they are IMPlying.
Syntax:
result = firstValue IMP secondValue
Description:
- Returns a different result from AND, OR or XOR.
- Evaluates if firstValue implies secondValue.
- If firstValue is true then secondValue must also be true.
- So if firstValue is true, and secondValue false, then the condition is false, otherwise it is true.
I appreciate the comments of this unloved relational operatoranother not so used operator is XOR, but often we use OR at the place of XOR with no problem because we use it (OR) evaluating conditions that are mutual self-excludent (conditions that if the first is TRUE the second cannot be TRUE and so we avoid the answer TRUE if all the two conditions are TRUE: think about the X of a sprite that moves itself into a square form 10 to 200 as X axis. We often type code like this.... if x+Xacceleration <= 10 OR x+Xacceleration >=200 then Xacceleration = - Xacceleration to change direction of the sprite... but the logical correct operator is XOR because if for a magic wonder X is in the same time <=0 and >=200 we change continuosely Xacceleration ( the direction of movement) getting a stuck sprite on the screen. But we are lucky that the two conditions are mutual excludent.
Hoping to input a color which is then to imply a gender but I'm missing something.
TYPE ColorType
val AS INTEGER 'holds color value and gender tags
title AS STRING 'name for the color
END TYPE
CONST Male = 1 'first bit
CONST Female = 2 'second bit
'A color with both bits off has no assignment, only the first bit is on is for males, only the second bit is on is for females, and both on would count as unisex
DIM Colors(10) AS ColorType
RESTORE colors
FOR i = 1 TO 10
'since the first two bits are used to identify sex, the base color values are multiples of 4; then a random sex assignment value is added to them
Colors(i).val = (4 * i) + INT(RND * 4)
READ Colors(i).title
PRINT "Color #";i; " is "; Colors(i).title; ", a color for "; GetGender$(Colors(i).val); " as can be seen by the color assignment value which is "; Colors(i).val MOD 4
NEXT i
colors:
DATA "RED","GREEN","BLUE","PURPLE","ORANGE","BROWN","BLACK","HEART","ATTACK","JACK"
FUNCTION GetGender$ (v)
IF v AND Male THEN m = 1
IF v AND Female THEN f = 2
'v MOD 4 would have worked too, but only because everything in this example program is neatly arranged with multiples of 4.
SELECT CASE m + f
CASE 0
GetGender$ = "which there are currently no assignments"
CASE 1
GetGender$ = "males!"
CASE 2
GetGender$ = "females!"
CASE 3
GetGender$ = "everyone!"
END SELECT
END FUNCTION
IMP
EQV
XOR
OR
AND
NOT
=, <>, <, >, <=, >=
+, - (subtraction)
MOD
\
*, /
- (negation)
^
Thanks bplus - i'll definitely look into it. A lot of interesting subjects in that Concise Guide to Formal Methods.
Type Colordata
Col as string
gender as string
End type
Dim Colors(10) as Colordata
Colors(1).Col="Blue"
Colors(1).gender="Male"
Function AssignGender(col as _unsigned long)
Male=1
Female=2
IF _BLUE32(col) > 200 AND _RED32(col) < 200 THEN AssignGender = Male
IF _RED32(col) > 200 AND _BLUE32(col) < 200 THEN AssignGender = Female
END FUNCTION
Basically it's a shortcut for:Or even just IF NOT condition1 OR condition2 THEN :)
IF NOT (condition1 AND NOT condition2) THEN...
And NOT A could be in B or NOT(in NOT B) ???
Or even just IF NOT condition1 OR condition2 THEN :)