w

Pi Calculator Tool

Calculate π to arbitrary decimal precision in your browser.

API Reference

Composable: usePiCalculator

const {
  isComputing, // ref<boolean> - whether computation is running
  currentPi, // ref<string> - current π value (e.g. "3.14159...")
  currentDigits, // ref<number> - number of decimal digits computed
  elapsedMs, // ref<number> - elapsed time in milliseconds
  stopReason, // ref<PiStopReason | null>
  consecutiveMatch, // ref<ConsecutiveMatch | null>
  activeWorkers, // ref<number> - number of active Web Workers
  startComputation, // (config: PiCalculatorConfig) => Promise<PiCalculationResult>
  stopComputation, // () => void
} = usePiCalculator();

Configuration

interface PiCalculatorConfig {
  stopMode: "digits" | "consecutive" | "both";
  targetDigits: number;
  consecutiveLength: number;
  multiThread: boolean;
  workerCount: number;
}

Store: piCalculator

toolsStore.piCalculator.bestResult; // string | null
toolsStore.piCalculator.bestDigits; // number
toolsStore.piCalculator.history; // PiHistoryRecord[]
toolsStore.updatePiCalculatorBestResult(pi, digits);
toolsStore.addPiCalculatorHistory(record);
Was this page helpful?