Skip to content

Instantly share code, notes, and snippets.

@miyaokamarina
miyaokamarina / inv.js
Last active July 11, 2023 21:51
Modular multiplicative inverse (mod 2^w) in JavaScript
/**
* Modular multiplicative inverse (mod 2^w).
*
* Find x, s.t.
*
* ax ≡ 1 (mod 2^w)
*
* Based on Hurchalla, J. (2022). “An Improved Integer Modular Multiplicative
* Inverse (modulo 2^w)”. https://arxiv.org/abs/2204.04342
*
@miyaokamarina
miyaokamarina / tu01.c
Last active October 23, 2023 11:04
Running TestU01 BigCrush in parallel
// The worker binary.
// Compile as
// gcc -Wall -O3 -o ./OUT_DIR/tu01 ./tu01.c
// -Iinclude -Llib -ltestu01 -lprobdist -lmylib -lm
#include <TestU01.h>
// Should provide:
// • void reset(); -- Init/reset the state.
@miyaokamarina
miyaokamarina / README.md
Last active November 30, 2023 10:39
Random 32-bit magic number generator

Random 32-bit magic number generator

A magic number for a binary file format should satisfy the following requirements:

  • invalid in UTF-8,

    Must contain either invalid bytes or invalid sequences.

  • is not ascending,
  • has no equal bytes,
  • has no bytes that are common in binary data, > 00, 01, 80, FF