binary operations

Blitz3D Forums/Blitz3D Programming/binary operations

David819(Posted 2004) [#1]
Hi Just wandering if blitz supports binary operations?


Ross C(Posted 2004) [#2]
http://www.blitzbasic.com/b3ddocs/command.php?name=Sar&ref=2d_a-z

http://www.blitzbasic.com/b3ddocs/command.php?name=Shl&ref=2d_a-z

http://www.blitzbasic.com/b3ddocs/command.php?name=Shr&ref=2d_a-z

you also have Xor, AND, OR, NOT

http://www.blitzbasic.com/b3ddocs/command.php?name=Xor&ref=2d_cat
http://www.blitzbasic.com/b3ddocs/command.php?name=And
http://www.blitzbasic.com/b3ddocs/command.php?name=Or
http://www.blitzbasic.com/b3ddocs/command.php?name=Not


David819(Posted 2004) [#3]
thanks, just one more thing, are there more and that?


Ross C(Posted 2004) [#4]
I think that's all there is. Pretty much all you need. What more are you looking for btw?


David819(Posted 2004) [#5]
I'm not really someone who is helping me read file formats was wandering if blitz supported binary operations and is begining to think that blitz3d is not a good programing enviroment. so i'm sending him an email with the binary operation commands in it so he can help me.


Ross C(Posted 2004) [#6]
Ah, well it has most of the ones i can think of :)


PetBom(Posted 2004) [#7]
What exactly are you looking for Goober? Like Ross C says I really can't figure out what binary operators you think you are missing.

There is of course the the MAGIC binary operation that always returns exactly what you want no matter what you put in or how you use it, but then again I've yet to see a programming language that has sucessfully implemented that... :)

//PetBom


Yan(Posted 2004) [#8]
That's ~, not Not ;o)


YAN


PetBom(Posted 2004) [#9]
Or:

Repeat
  answer = "?"
  For i = 0 to infinity-1
    tmp = Rand(0,infinity-1)
    answer = ConvertToCharsInGroupsByThree(tmp)
    Print answer
  Next
Forever


If you have enough time you'll evetually find the correct
answer to any question you might have. :)

Sorry...pressed the post button to early by misstake. And sorry for messing up this thread. I guess I'm just bored :)



David819(Posted 2004) [#10]
Can some make sense of this for me please?
try searching net to see what do they need. its a binary math
for example
1 and 1 = 1, 1 and 0 = 0, 0 and 1 = 0, 0 and 0 = 0
and returns 1 if both operands are 1 else it returns 0
or returns 1 if at least one operand is 1
not returns opposite of operand
xor switches operand1 if operand2 is 1
and so on


koekjesbaby(Posted 2004) [#11]
Print 1 And 1
Print 1 And 0
Print 0 And 1
Print 0 And 0
Print "---"
Print 1 Or 1
Print 1 Or 0
Print 0 Or 1
Print 0 Or 0
Print "---"
Print 1 Xor 1
Print 1 Xor 0
Print 0 Xor 1
Print 0 Xor 0
Print "---"
Print Not 1
Print Not 0
WaitKey


it never hurts to try something, or actually read what people reply, before you ask.


David819(Posted 2004) [#12]
thanks, i did read it but did not make sense of what it mean. thanks again for the help.


jfk EO-11110(Posted 2004) [#13]
See it like when you compare two things and the result is true or false.

If a=1 and b=1 then both are 1, so a and b (are both set) is true. If a=1 OR b=1 then at least one ofem is set, so the result is true when at least one of them is not zero.

Example of usage:
if (mousedown(1) or mousedown(2)) = true then ...
is diffrent from
if (mousedown(1) AND mousedown(2)) = true then ...


jfk EO-11110(Posted 2004) [#14]
oh, and note, bitwise boolean operators can not only be used to compare stuff, but also to manipulate the bits of numbers. eg:

a=%11110
b=%01011

c= a and b

c= %01010

the bits in c are set if they are set in a AND b.

an other example:

a=%100011
b=%001101

c= a OR b
c is %10111

the bits in c are set if they are set eighter in a or in b (or in both).


David819(Posted 2004) [#15]
thanks for the help.