eolas/zk/Bitwise_operators.md

31 lines
728 B
Markdown
Raw Normal View History

2024-04-20 14:50:05 +01:00
---
id: t127
title: Bitwise_operators
2024-04-20 15:00:04 +01:00
tags: [binary]
created: Saturday, April 20, 2024
2024-04-20 14:50:05 +01:00
---
2024-04-20 15:00:04 +01:00
# Bitwise operators
2024-04-20 14:50:05 +01:00
2024-04-20 15:00:04 +01:00
In addition to mathematical, logical and comparison operators, there are
_bitwise operators_. These operators execute conditions based on the actual bits
of a value rather than the values that the bits are encoded to represent.
2024-04-20 14:50:05 +01:00
2024-04-20 15:10:04 +01:00
Bitwise operators are typically represented with single characters of existing
operators, e.g. `&` instead of `&&`:
| Bitwise operation | Operator |
| ----------------- | ------------- |
| AND | `&` |
| OR | (single pipe) |
| NOT | `~` |
An example of using the `&` operator:
```py
x =5
y = 3
```
2024-04-20 15:00:04 +01:00
## Related notes