Skip to content

itsRevela/BirthdayPi

Repository files navigation

BirthdayPi - Find Your Birthday (or Any Number) in π

BirthdayPi is a Windows-friendly tool that searches for a digit string inside the digits of π after the decimal point (π = 3.<digits>). It uses a responsive Tkinter GUI and can optionally reuse cached π digits stored in RAM (SharedMemory) or in a .bpi cache file.

You can use it in:

  • Birthday Mode: enter MM/DD/YYYY and search for MMDDYYYY
  • Number Mode: search for any numeric string you provide

What's in the releases page

  • birthdaypi.exe
    Prebuilt Windows executable. Contains the birthdaypi_cache_1000000000.bpi file and is automatically unpacked upon launch. VirusTotal hates this behavior, so feel free to build the exe yourself or just run from source (Python).

  • birthdaypi_cache_1000000000.bpi
    A .bpi cache containing 1,000,000,000 digits of π (digits after the decimal). Download this if you're planning on running from source (Python >=3.8)

What’s in this repo

  • birthdaypi.py
    Main GUI application.

  • resource_unpack.py
    Helper that copies bundled resources (like the 1B cache file) into the current directory on first run. Only needed when packing your own Windows executable.

  • piconvert.py
    Converter utility for creating .bpi cache files from π text files.

  • pi_max_precision.py
    Reports MPFR maximum precision and estimates safe π digit limits for the MPFR approach.

  • pi_race_benchmark.py / pi_crossover_headtohead.py
    Benchmark scripts for performance comparisons.

  • requirements.txt
    Python dependency list (runtime).


Quick start (Windows Executable)

  1. Navigate to the releases page and download birthdaypi.exe.
  2. Run:
    • dist/birthdaypi.exe

First run cache “unpack”

On first run, the EXE will unpack the 1B Pi digit file in the CWD:

birthdaypi_cache_1000000000.bpi

When presented with the GUI, click on load and select the newly unpacked birthdaypi_cache_1000000000.bpi file.


Running from source (Python)

Requirements

  • Python 3.8+

Optional:

  • Download birthdaypi_cache_1000000000.bpi from the releases page (1 billion digits of Pi)

Recommended:

    1. Create your Python virtual environment: python -m venv venv
    1. Enter your Python virtual environment: .\venv\Scripts\activate

Install dependencies:

pip install -r requirements.txt

Run the GUI:

python birthdaypi.py

Using the app

Search modes

  • Click Mode to toggle between:
    • Birthday: enter MM / DD / YYYY
    • Number: enter any numeric string

Index meaning

When a match is found, the app reports the index counted in digits AFTER the decimal point, starting at 1:

  • π = 3.14159...
  • The digit 1 immediately after the decimal is index 1

Saving / loading caches

  • Save writes your currently cached digits to a .bpi file.
  • Load loads a .bpi file into a GUI-owned SharedMemory cache.

.bpi file format

  • 12-byte header:
    • b"BPI1" magic (4 bytes)
    • digit count (uint64, 8 bytes, little-endian)
  • followed by exactly digit_count bytes of ASCII digits (09)

MPFR precision limit (important)

The GUI can compute π digits using MPFR (gmpy2.const_pi()), but MPFR has a build-dependent maximum precision.
On many Windows builds, you may hit a practical limit around the low hundreds of millions of digits.. If you need more, use a .bpi cache file instead (like the included 1B cache).

Use:

python pi_max_precision.py

…to see the max precision for your environment and estimate safe digit limits. This is only relevant to users that wish know the precision limit for calculating their own Pi numbers using BirthdayPi. The key takeaway is that BirthdayPi can only calculate to a certain extent. In my testing, it's ~323,227,792 digits, give or take a lil' overhead.


Utilities

Convert a π text file into .bpi

Use piconvert.py to convert large text files of π digits into the .bpi format for fast loading/searching.

python piconvert.py

(Depending on your version of piconvert.py, it may open file pickers or accept CLI arguments.)

Benchmarks

  • pi_race_benchmark.py: compare approaches and throughput
  • pi_crossover_headtohead.py: crossover / head-to-head benchmark

Run:

python pi_race_benchmark.py
python pi_crossover_headtohead.py

Packaging notes (PyInstaller)

If you rebuild the EXE yourself, include the cache file as bundled data:

pyinstaller --noconsole --onefile birthdaypi.py --add-data "saves\birthdaypi_cache_1000000000.bpi;saves"

resource_unpack.py handles copying it out to the current directory on first run.


License

MIT

About

Find Your Birthday (or Any Number) in π

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages