View Full Version : C language operation Order Question.
toalan
Jul 15th, 2005, 01:55 PM
I just have a quicky, i tried to google it but did not find much.
does a bit shift (<<) have higher priority over a power (^), I am trying to code up the Xtea encryption algorithim and I am not sure bout the order.
toalan
Jul 15th, 2005, 02:38 PM
nm the (^) is an exclusive OR, now everything makes more sense
toalan
Jul 15th, 2005, 02:54 PM
bitshift has higher priority than exclusive OR, Xtea here I come.
devious9191
Jul 15th, 2005, 03:13 PM
Glad to be of help.
Nyte
Jul 15th, 2005, 05:19 PM
When in doubt, add some brackets :)
aquariaguy
Jul 15th, 2005, 05:56 PM
Is that even english?!
gman
Jul 15th, 2005, 06:02 PM
Is that even english?!
He did say C. ;)
toalan
Jul 15th, 2005, 06:59 PM
The syntax is C, I already solved all my issues and have successfully implemented xtea.
xtea is an encryption/decryption algorithim, it is supposed to be one of the few cyphers that has not been broken yet. I think xbox uses xtea or a slight variant of it. I was gonna do DES of AES encryption but they are not very computationally friendly. I am using xtea to encrypt my programs so people can not steal my work.
CheapScotsman
Jul 15th, 2005, 07:43 PM
the average programmer can't remember the properity of operations (as your post atests to) so ... to be a good programmer, making your code more readable and unambiguous (without having to look it up) ...
Add the brackets !!!
toalan
Jul 15th, 2005, 09:28 PM
I totally agree on adding brackets, I was looking at some reference code that had no brackets. Even the reference code said many people confuse the order of operation, but they still did not clarify.
CheapScotsman
Jul 16th, 2005, 03:29 AM
Whew ... glad you are going to make it right. See how much easier the original author of that code would have made it ...
For future reference ... http://www.swansontec.com/sopc.htm and I wouldn't use the comma or Ternary Operator for the same reasons.
toalan
Jul 19th, 2005, 06:58 PM
If by any chance anyone is interested in an XTEA bootloader for AVR, here is my work. It is about 80% complete.
http://www.14point7.com/AVR.htm