First step for a bit manipulation page
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:
53
content/post/bit-magic/index.md
Normal file
53
content/post/bit-magic/index.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
---
|
||||||
|
# Documentation: https://sourcethemes.com/academic/docs/managing-content/
|
||||||
|
|
||||||
|
title: "Bit magic in C (and C++)"
|
||||||
|
subtitle: ""
|
||||||
|
summary: ""
|
||||||
|
authors: []
|
||||||
|
tags: []
|
||||||
|
categories: []
|
||||||
|
date: 2020-06-13T19:01:19+02:00
|
||||||
|
lastmod: 2020-06-13T19:01:19+02:00
|
||||||
|
featured: false
|
||||||
|
draft: true
|
||||||
|
|
||||||
|
# Featured image
|
||||||
|
# To use, add an image named `featured.jpg/png` to your page's folder.
|
||||||
|
# Focal points: Smart, Center, TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight.
|
||||||
|
image:
|
||||||
|
caption: ""
|
||||||
|
focal_point: ""
|
||||||
|
preview_only: false
|
||||||
|
|
||||||
|
# Projects (optional).
|
||||||
|
# Associate this post with one or more of your projects.
|
||||||
|
# Simply enter your project's folder or file name without extension.
|
||||||
|
# E.g. `projects = ["internal-project"]` references `content/project/deep-learning/index.md`.
|
||||||
|
# Otherwise, set `projects = []`.
|
||||||
|
projects: []
|
||||||
|
---
|
||||||
|
|
||||||
|
# Set a bit
|
||||||
|
```c
|
||||||
|
// Set one bit high at position "bit" in input and store to output
|
||||||
|
output = input | (1 << bit);
|
||||||
|
// Shorthand
|
||||||
|
variable |= (1 << bit);
|
||||||
|
```
|
||||||
|
|
||||||
|
# Clear a bit
|
||||||
|
```c
|
||||||
|
// Clear one bit high at position "bit" in input and store to output
|
||||||
|
output = input & ~(1 << bit);
|
||||||
|
// Shorthand
|
||||||
|
variable &= ~(1 << bit);
|
||||||
|
```
|
||||||
|
|
||||||
|
# Toggle a bit
|
||||||
|
```c
|
||||||
|
// Clear one bit high at position "bit" in input and store to output
|
||||||
|
output = x ^ (1 << bit);
|
||||||
|
// Shorthand
|
||||||
|
variable ^= (1 << bit);
|
||||||
|
```
|
Submodule themes/academic updated: ff252a6a74...8d75e9e27a
Reference in New Issue
Block a user