ludic/ns-bigint.html
2026-09-17 22:10:03 +00:00

22 lines
No EOL
4.4 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>BigInt — Ludic</title>
<meta name="description" content="Arbitrary-precision integers with no upper bound, for idle/incremental counters, exact huge currencies, and score arithmetic that a 32- or 64-bit int would…">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="docs.css">
</head>
<body>
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
<main class="wrap item">
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">BigInt</span></div>
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">BigInt</h1></div>
<p class="ns-blurb">Arbitrary-precision integers with no upper bound, for idle/incremental counters, exact huge currencies, and score arithmetic that a 32- or 64-bit <code>int</code> would overflow. A <code>BigInt</code> is a sign-magnitude number stored as base-1e9 limbs, so every operation is <strong>exact</strong> and therefore deterministic — bit-identical on every platform, with no binary floating point. Build one with <code>BigInt.from</code> (an <code>int</code>) or <code>BigInt.parse</code> (decimal text), combine with <code>add</code> / <code>sub</code> / <code>mul</code> / <code>pow</code> / <code>div</code> / <code>mod</code>, compare with <code>cmp</code> / <code>eq</code> / <code>is_zero</code>, and render with <code>str</code>. Arguments are positional. The runtime is spliced in only when a program mentions <code>BigInt.*</code>.</p>
<div class="ns-methods"><a class="ns-method" href="bigint-from.html"><code class="nm-sig">BigInt.from(value) -&gt; BigInt</code><span class="nm-tip">Turn a plain int into a BigInt.</span></a><a class="ns-method" href="bigint-parse.html"><code class="nm-sig">BigInt.parse(text) -&gt; BigInt</code><span class="nm-tip">Parse decimal text into a BigInt.</span></a><a class="ns-method" href="bigint-add.html"><code class="nm-sig">BigInt.add(a, b) -&gt; BigInt</code><span class="nm-tip">Exact sum of two big integers.</span></a><a class="ns-method" href="bigint-sub.html"><code class="nm-sig">BigInt.sub(a, b) -&gt; BigInt</code><span class="nm-tip">Exact difference of two big integers.</span></a><a class="ns-method" href="bigint-mul.html"><code class="nm-sig">BigInt.mul(a, b) -&gt; BigInt</code><span class="nm-tip">Exact product of two big integers.</span></a><a class="ns-method" href="bigint-neg.html"><code class="nm-sig">BigInt.neg(a) -&gt; BigInt</code><span class="nm-tip">Negate a big integer.</span></a><a class="ns-method" href="bigint-pow.html"><code class="nm-sig">BigInt.pow(a, exp) -&gt; BigInt</code><span class="nm-tip">Raise a big integer to an int power.</span></a><a class="ns-method" href="bigint-div.html"><code class="nm-sig">BigInt.div(a, d) -&gt; BigInt</code><span class="nm-tip">Divide a big integer by an int (toward zero).</span></a><a class="ns-method" href="bigint-mod.html"><code class="nm-sig">BigInt.mod(a, d) -&gt; int</code><span class="nm-tip">Remainder of a big integer divided by an int.</span></a><a class="ns-method" href="bigint-cmp.html"><code class="nm-sig">BigInt.cmp(a, b) -&gt; int</code><span class="nm-tip">Compare two big integers: -1, 0, or 1.</span></a><a class="ns-method" href="bigint-eq.html"><code class="nm-sig">BigInt.eq(a, b) -&gt; bool</code><span class="nm-tip">True when two big integers are equal.</span></a><a class="ns-method" href="bigint-is_zero.html"><code class="nm-sig">BigInt.is_zero(a) -&gt; bool</code><span class="nm-tip">True when a big integer is zero.</span></a><a class="ns-method" href="bigint-to_int.html"><code class="nm-sig">BigInt.to_int(a) -&gt; int</code><span class="nm-tip">Narrow a big integer to a plain int (clamped).</span></a><a class="ns-method" href="bigint-str.html"><code class="nm-sig">BigInt.str(a) -&gt; string</code><span class="nm-tip">Render a big integer as decimal text.</span></a></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>