Skip to content

Instantly share code, notes, and snippets.

@shuax
shuax / fast_pow10_division.md
Created August 31, 2023 02:31 — forked from loicmolinari/fast_pow10_division.md
Fast power-of-10 division using multiply and shift magic constants in a look-up table instead of a costly division operation.
U64
DivPow10(U64 a, S64 index)
{
    ASSERT(index >= 0 && index < 19);

    // Generated using libdivide's reference implementation adapted to 64-bit unsigned integers.
    static const struct { U64 mul; U32 shr1; U32 shr2; } kPow10Magics[19] = {
        { 0xcccccccccccccccd,  0,  3 },  // 10^1
        { 0x28f5c28f5c28f5c3,  2,  2 },  // 10^2
import os
import re
import zlib
import urllib.request
from struct import unpack
class QQWayIPSeekerUpdate():
@classmethod
def __download_meta(cls):