Numerical Precision logo

Numerical Precision

Community
0xBakeer
numerical-precision

Avoiding floating-point mistakes in code that computes money, statistics, physics or geometry - when to use integers or Decimal, comparing with tolerances, summation order, catastrophic cancellation, float32 limits, and rounding for display.

Overview

Publisher0xBakeer
RepositoryTandemLLM
Skill namenumerical-precision
Stars
75
Forks
14
Bundled files
Instructions only
LicenseAGPL-3.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by 0xBakeer on GitHub. Read the source before you install it.

Installation

Install the Numerical Precision AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/0xBakeer/TandemLLM/tree/main/packages/library/numerical-precision
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/0xBakeer/TandemLLM.git /tmp/TandemLLM
mkdir -p .claude/skills
cp -r /tmp/TandemLLM/packages/library/numerical-precision .claude/skills/numerical-precision
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Numerical Precision in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Numerical Precision on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Numerical Precision is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Numerical precision

Rules:

  • Money and counts: integers (cents) or Decimal with a fixed quantize; never float. Sum in integers, convert for display.
  • Compare floats with a tolerance: math.isclose(a, b, rel_tol=1e-9, abs_tol=1e-12) or np.allclose; never == on computed values. Choose and state the tolerance.
  • Know the limits: float64 holds about 15 significant digits; float32 about 7; integers above 2^53 lose precision in JavaScript and in float64.
  • Sum many values with math.fsum or np.sum (pairwise), not a Python loop; sort small to large for a plain loop.

What goes wrong:

  • 0.1 + 0.2 != 0.3; a test with == flaps.
  • A running total in float drifts after 10^6 additions; the ledger does not balance.
  • Variance comes out negative from the one-pass formula.

Check: a known case with an exact answer (sum of 0.1 ten times, a variance of a fixed list, a money total), the error against the exact value printed, and the tolerance used stated.

Done when:

  • One known-answer test per numeric routine with the absolute and relative error printed.
  • Tolerances stated in the tests (isclose arguments or allclose values).
  • Money paths use integers or Decimal (grep shows no float arithmetic on amounts).

Reference

python
import math
from decimal import Decimal, ROUND_HALF_EVEN, getcontext
print(sum([0.1] * 10) == 1.0, math.fsum([0.1] * 10) == 1.0)       # False True
cents = sum(int(round(float(p) * 100)) for p in ["19.99", "0.01"]); print(cents / 100)
d = (Decimal("19.99") * Decimal("1.19")).quantize(Decimal("0.01"), rounding=ROUND_HALF_EVEN)
assert math.isclose(0.1 + 0.2, 0.3, rel_tol=1e-9)

Welford mean and variance (one pass, stable):

python
def mean_var(xs):
    n = 0; mean = 0.0; m2 = 0.0
    for x in xs:
        n += 1; d = x - mean; mean += d / n; m2 += d * (x - mean)
    return mean, (m2 / (n - 1) if n > 1 else 0.0)

Log-sum-exp: m = max(xs); math.log(sum(math.exp(x - m) for x in xs)) + m. Stable forms: math.log1p(x) for log(1+x), math.expm1(x), math.hypot(a, b) for sqrt(a*a+b*b), 2*math.sin(x/2)**2 for 1-cos(x). NumPy: np.sum is pairwise and fine; dtype=np.float64 for accumulators even when data is float32; np.allclose(a, b, rtol=1e-5, atol=1e-8) defaults are loose, tighten them on purpose. JavaScript: integers safe up to Number.MAX_SAFE_INTEGER (2^53-1); beyond that BigInt. Money in cents as integers; Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }) for display. Geometry: epsilon tests for collinearity abs(cross) < 1e-9 * scale; never compare slopes. Known-answer sources: math.fsum as the exact sum; statistics.variance from the standard library; Decimal with getcontext().prec = 50 as a high-precision oracle.

More rules:

  • Avoid subtracting nearly equal numbers (variance as E[x^2]-E[x]^2, 1 - cos(x) for small x); use the stable formula (Welford, 2*sin(x/2)^2, log1p, expm1, hypot).
  • Round only at output: round(x, 2) for display, Decimal.quantize for money, and say which rounding mode (half-even is Python's default).

More pitfalls:

  • Overflow to inf or underflow to 0 in exp of large values; use the log-sum-exp trick.
  • Dividing by a tiny number from a near-cancellation; the result explodes.

Frequently asked questions

What does the Numerical Precision AI skill do?

Avoiding floating-point mistakes in code that computes money, statistics, physics or geometry - when to use integers or Decimal, comparing with tolerances, summation order, catastrophic cancellation, float32 limits, and rounding for display.

Why use Numerical Precision on TypingMind?

Because you install it once and use it with any model. Numerical Precision is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Numerical Precision in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/0xBakeer/TandemLLM/tree/main/packages/library/numerical-precision. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Numerical Precision?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Numerical Precision?

As many as you like. As long as a model supports skills, you can use Numerical Precision with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Numerical Precision AI skill free?

Yes. It is published on GitHub by 0xBakeer under the AGPL-3.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇