Skip to content

Instantly share code, notes, and snippets.

View joson1's full-sized avatar

Alanwake joson1

View GitHub Profile
@joson1
joson1 / .md
Created November 27, 2021 03:29 — forked from joepie91/.md
Prefix codes (explained simply)

A "prefix code" is a type of encoding mechanism ("code"). For something to be a prefix code, the entire set of possible encoded values ("codewords") must not contain any values that start with any other value in the set.

For example: [3, 11, 22] is a prefix code, because none of the values start with ("have a prefix of") any of the other values. However, [1, 12, 33] is not a prefix code, because one of the values (12) starts with another of the values (1).

Prefix codes are useful because, if you have a complete and accurate sequence of values, you can pick out each value without needing to know where one value starts and ends.

For example, let's say we have the following codewords: [1, 2, 33, 34, 50, 61]. And let's say that the sequence of numbers we've received looks like this:

1611333425012

@joson1
joson1 / loopbuffer.md
Created June 14, 2019 14:09
loop buffer 环形缓冲区

环形缓冲区

大小设置为2的N次幂时间最优

#include <iostream>
#define USART_REC_LEN 4
using namespace std;
@joson1
joson1 / fast_sqrt.md
Last active June 10, 2019 05:44
快速开平方

快速开平方

比(float)(1.0/sqrt(x))快大约4倍

float Q_rsqrt( float number ){
   long i;
   float x2, y;
   const float threehalfs = 1.5F;
  x2 = number * 0.5F;
 y = number;