More bitmagic. Theme update
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -10,7 +10,7 @@ categories: []
|
|||||||
date: 2020-06-13T19:01:19+02:00
|
date: 2020-06-13T19:01:19+02:00
|
||||||
lastmod: 2020-06-13T19:01:19+02:00
|
lastmod: 2020-06-13T19:01:19+02:00
|
||||||
featured: false
|
featured: false
|
||||||
draft: true
|
draft: false
|
||||||
|
|
||||||
# Featured image
|
# Featured image
|
||||||
# To use, add an image named `featured.jpg/png` to your page's folder.
|
# To use, add an image named `featured.jpg/png` to your page's folder.
|
||||||
@ -57,4 +57,31 @@ output = x ^ (1 << bit);
|
|||||||
variable ^= (1 << bit);
|
variable ^= (1 << bit);
|
||||||
// Multiple bits
|
// Multiple bits
|
||||||
variable ^= (0b101 << bit);
|
variable ^= (0b101 << bit);
|
||||||
|
```
|
||||||
|
|
||||||
|
# Math
|
||||||
|
```c
|
||||||
|
// Division using bitshift
|
||||||
|
output = input >> 1; // Divide by 2
|
||||||
|
output = input >> 2; // Divide by 4
|
||||||
|
output = input >> 3; // Divide by 8
|
||||||
|
// Multiply using bitshifting
|
||||||
|
output = input << 1; // Multiply by 2
|
||||||
|
output = input << 2; // Multiply by 4
|
||||||
|
output = input << 3; // Multiply by 8
|
||||||
|
```
|
||||||
|
|
||||||
|
# Set X number of bits high.
|
||||||
|
```c
|
||||||
|
output = (0b1 << X) -1;
|
||||||
|
```
|
||||||
|
|
||||||
|
# Miccelean
|
||||||
|
```c
|
||||||
|
// Check if number is ODD
|
||||||
|
if( (num & 1) == 1) {};
|
||||||
|
// Flip signed integer
|
||||||
|
num = ~num + 1;
|
||||||
|
// Power of two
|
||||||
|
num > 0 && (num & (num - 1)) == 0;
|
||||||
```
|
```
|
Submodule themes/academic updated: c4f0317cdf...6bf282275a
Reference in New Issue
Block a user