## Computer Science 237 |

**Lecture 04: Signed Arithmetic, Logical Operations****Date: September 15, 2006**

* *

- Announcements
- Computer Science Colloquium today - CS Students talk about their summer work experiences

- Lab continues - ask questions when stuck
- In order to use the turnin command, your cs237 directory will
need to have world execute permission:
`chmod 711 cs237`This allows turnin to change into your directory to be able to copy out the files. Alternately, you can copy the files you wish to submit out to your home directory or other more public area, turn them in, then remove them. - Some people have had trouble with turnin on the Macs. I recommend using the turnin command on the FreeBSD systems.

- In order to use the turnin command, your cs237 directory will
need to have world execute permission:
- Math
- signed addition
- 2's complement - OK if carry out == carry in for sign bit
- 1's complement - need to add any carry out back in

- signed multiplication
- 2's complement only - need sign extension, then OK
- powers of 2 - bit shifts!

- signed addition
- C logical operators
- Traditional logical operators: (
`==`

,`!`

,`!=`

,`&&`

,`||`

) - note short-circuit evaluation - Bitwise operators:
- bitwise AND (
`&`

) - result true when both operands true - bitwise OR (
`|`

) - result true when either operand true - bitwise XOR (
`^`

) - result true when exactly one operand true - bitwise complement (
`~`

) - result true when operand false - Addition (
`+`

)*vs.*bitwise XOR (`^`

). - Bitwise shift by n (
`x>>n`

or`x<<n`

)

- bitwise AND (

- Traditional logical operators: (

* *

- shiftyproduct