return values

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

return values

Post by sid6.7 » Sat Aug 26, 2006 11:08 am

return values

not sure i understand them very well
is thier a tut here or a chart for doing
these calc's or a simple formula?

i've seen AND OR and such used
also....not sure what they mean...

i vaugly the notion that it also
has a postivie or negative thing too?

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Re: return values

Post by moneo » Sun Aug 27, 2006 12:55 am

sid6.7 wrote:return values

not sure i understand them very well
is thier a tut here or a chart for doing
these calc's or a simple formula?

i've seen AND OR and such used
also....not sure what they mean...

i vaugly the notion that it also
has a postivie or negative thing too?
What do you mean by RETURN VALUES?

AND, OR, XOR and a few others are logical operators, which are work differently than arithmetic operators like + - * /.
These logical operators perform bit-wise operations on the operands.

AND: When you do:
x = a AND b
Then "x" will have a 1 bit in those bit positions where "a" has a 1 bit as well as (AND) "b" has a 1 bit in the same position.
Example: a = 6 : b = 7 : x = a AND b
The result in x will be 6
because bitwise a is 110
and b = 111
They both only have 1 bits on in the first two position, which results in
a 110 or 6.

OR:
x = a OR b
The "x" will have a 1 bit in those bit positions where either (OR) "a" or "b" has a 1 bit in the same position.
Example: a = 5 : b = 2 : x = a OR b
The result in x will be 7
because bitwise a is 101
and b = 010
Looking at both "a" and "b" bit by bit, there is at least one 1 bit in each bit position, which results in a 111 or 7.

XOR:
The XOR (Exclusive OR) is very similar to the OR, with one exception. If the same bit position of both "a" and "b" already have a 1 bit in both, then the result will be zero in that bit position.
Example: a = 5 : b = 2 : x = a XOR b
The result in x will be 7, just like the OR, because no bits were both on in the same bit position.

But, when a = 5 : b = 3 : x = a XOR b
The result in x will be 6
because bitwise a is 101
and b = 011
Notice that the least significant (last) bit of "a" and "b" are both 1 (on).
Looking at both "a" and "b" bit by bit, there is at least one 1 bit in each of the first two bit positions, but both are on in the last position, which results in 110 or 6.

Why you would need to use these logical operatiors is the subject for a tutorial.

*****

User avatar
Skyler
Coder
Posts: 16
Joined: Wed Jun 07, 2006 4:15 pm
Location: Delta Quadrant

Post by Skyler » Mon Aug 28, 2006 3:52 pm

Do you mean

Code: Select all

RETURN 0
?
For God so loved the world he gave His only begotten Son that whosoever believeth on Him shall have everlasting life.
John 3:16

User avatar
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 » Mon Aug 28, 2006 4:15 pm

no moneo answered what i was looking for.....

Post Reply