|
-
Mar 4th, 2001, 01:11 PM
#1
Thread Starter
Fanatic Member
I have a few questions on operator presedence that i need confirming.
I have the following operators. The lower the number after the operator, the higher the presedence.
Equals: "=" 0
Is equal to: "==" 1
Not equal to: "!=" 1
Greater than or equal to: ">=" 1
Less than or equal to: "<=" 1
Less than: "<" 1
More than: ">" 1
Power: "^" 2
Multiply: "*" 3
Division: "/" 3
Integer Division: "\" 3
Mod "%" 3
And "&" 4
Or "|" 4
Addition "+" 4
Minus "-" 4
What i need to know is this.
1. Is the 'integer division operator' (\) of equal presedence to "/" and "*"? (as i assume it is)
2. I am assuming that '&' and "|" are of the same presedence as "+" and "-", and that "%" is of the same presedence as "/" and "*". Is this correct?
1. Basically, are they in the correct order of presedence? 
Any contributions appreciated. Thanks in advance.
Later
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
-
Mar 4th, 2001, 05:19 PM
#2
Frenzied Member
Are "And" & "or" same level?
I thought that "And" & "Or" had a different precedence, but I am not at all sure. The others seem correct.
There must be literature on this subject. I would advise checking the Web or your your local library.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Mar 4th, 2001, 07:56 PM
#3
transcendental analytic
AND and OR have same precedence in logics, but in vb AND has a higher precedence, haven't tested other languages of this. Also all mathematical operators are higher than comparation operators, which in turn are higher than all logical operators.
INTEGER DIVISION IS LOWER THAN FLOATIN PTDIVISION AND MULTIPLICATION, this caused me quite much trouble, until i discovered it was this way.
For comparations:
equality is strongest = (==)
next comes <> (!=)
<
>
<=
>=
For logical operators also, Implication is lower than Equivalence, which is very odd, Xor which doesn't appear in logics, is lower than Or but higher than Eqv and Imp.
And one more thing for mathematical operators, -X that is negation operator, not substraction, is higher than multiplication and lower than exponentation
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Mar 4th, 2001, 08:04 PM
#4
transcendental analytic
ok a revision:
mathematical:
^
-
*,/
\
Mod
+-
Comparation:
=
<>
<
>
<=
>=
Logical:
not
And
Or
Xor
Eqv
Imp
Note, this is at least how vb orders operators precedence.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Mar 4th, 2001, 09:49 PM
#5
Frenzied Member
In boolean algebra, A.B+C where . is 'and', and + is 'or' is equivalent to (A.B)+C so err... basically what I am saying is AND is higher precendence than OR in logic too.
Harry.
"From one thing, know ten thousand things."
-
Mar 5th, 2001, 10:59 AM
#6
transcendental analytic
Hmm, maybe there are different schemes for different purposes, here's from our logic course:
x:=e (textual substitution)
. (functional application)
unary prefix operators: +,-,¬,#,~,P
**
.,/,%, mod, gcd
+,- (°,È,Ç,Ä,×) symbol fonts
(¯*) symbols again
#
<|, |>, ^
=, <, > (Î,Ì,Í,É,Ê,ç) symbols (*)
and, or (*)
=>, <=
eqv (*)
the cases with (*) may have a slash trough them indicating negation.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Mar 5th, 2001, 03:35 PM
#7
Thread Starter
Fanatic Member
Thanks
Thanks for the response. I have the problem sorted now.
Later
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|