Levenshtein coding

Uses your system voice; voice and rate in settings.

Snapshot

≈ 1 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

Levenshtein coding is a universal code encoding the non-negative integers developed by Vladimir Levenshtein.

Levenshtein coding is a universal code encoding the non-negative integers developed by Vladimir Levenshtein. void levenshteinEncode(char* source, char* dest) { IntReader intreader(source); BitWriter bitwriter(dest); while (intreader.hasLeft()) { int num = intreader.getInt(); if (num == 0) bitwriter.outputBit(0); else { int c = 0; BitStack bits; do { int m = 0; for (int temp = num; temp > 1; temp>>=1) // calculate floor(log2(num)) ++m; for (int i=0; i > i) & 1); num = m; ++c; } while (num > 0); for (int i=0; i 0) bitwriter.outputBit(bits.popBit()); } } } void levenshteinDecode(char* source, char* dest) { BitReader bitreader(source); IntWriter intwriter(dest); while (bitreader.hasLeft()) { int n = 0; while (bitreader.inputBit()) // potentially dangerous with malformed files. ++n; int num; if (n == 0) num = 0; else { num = 1; for (int i = 0; i

See also

Elias omega coding Iterated logarithm

References

Text derived from https://en.wikipedia.org/w/index.php?oldid=1261421333 under CC BY-SA 4.0; modifications have been made.

Sources cited in this revision

Extracted from the cited revision's reference blocks; absent citations are not invented.