derivado de nique_372/BigNumberByLeo
Fast TSN library for large numbers of X number of bits (unsigned and signed)
- MQL5 95.2%
- MQL4 4.8%
| Nome do ficheiro | Mensagem do último cometimento | Data do último cometimento |
|---|---|---|
| Src | ||
| Test | ||
| BigNumberByLeo.mqproj | ||
| dependencies.json | ||
| LICENSE | ||
| README.md | ||
Arbitrary-precision unsigned integer library for MQL5.
Limb-based (ulong[]) arithmetic, ~90% complete.
Main Features
- Arbitrary-precision
BigUInteger: base type backed by aulong[]limb array, construct from along, a decimalstring, raw bytes, or an existing limb array - Full arithmetic:
+,-,*,/,%— each with bothBigUIntegerandlongoperands, plus in-place (+=,-=, etc.) variants - Bitwise operators:
&,|,^,~,<<,>>, both in-place and returning a new value - Comparisons:
>,>=,==,!=,<,<=, plusIsZero()/IsNotZero() - Fast multiplication: schoolbook multiplication (working), with Karatsuba for large operands in progress
- Modular exponentiation:
PowMod(exp, mod)— pending implementation - Primality testing:
IsProbablePrime(rounds)(Miller-Rabin style) — pending implementation - GCD: standard
Gdc()(working) and extended GCD (GdcExtendedRetX, for modular inverse) — pending implementation - Byte/string conversion:
FromBytesLE/BE,ToBytesLE/BE,ToString - Random generation:
InitRandom<TRandom>(limbs), pluggable with any RNG source - Low-level numeric utilities (
CNumberUtils): 64x64→128 multiply, 128/64-bit division, hex string conversion
Usage examples
Basic arithmetic:
#include "Src\\Base\\Main.mqh"
ulong v[];
ArrayResize(v, 1);
v[0] = 64;
TSN::BigUInteger integer(v, 1);
integer /= 8; // 8
integer %= 6; // 2
Standard GCD:
TSN::BigUInteger a("123456789", 10);
ulong gcd = a.Gdc(987654321);
PowMod,IsProbablePrimeandGdcExtendedRetXare declared in the API but not yet implemented — see Roadmap.
Repository Structure
BigNumberByLeo/
├── Src/
│ ├── Base/ # BigUInteger core (arithmetic, bitwise, comparisons, primality, GCD)
│ └── Utils/ # Low-level numeric helpers (CNumberUtils)
└── Test/ # Scripts covering ops, division, multiplication, misc
Requirements
See dependencies.json for the full list.
- MetaTrader 5, build 5430+
- Depends on
TsnTables(public, installed automatically viatsndep)
Installation
cd "C:\Users\YOUR_USER\AppData\Roaming\MetaQuotes\Terminal\YOUR_ID\MQL5\Shared Projects"
tsndep install "https://forge.mql5.io/nique_372/BigNumberByLeo.git"
Requires the tsndep package, available on PyPI. It automatically downloads and installs all declared dependencies.
Quick Start
1. Include the library:
#include "..\\BigNumberByLeo\\Src\\Base\\Main.mqh"
2. Use it:
TSN::BigUInteger a("340282366920938463463374607431768211456", 10);
TSN::BigUInteger b(2);
TSN::BigUInteger c = a * b;
License
Read Full License By downloading or using this repository, you accept the license terms.
Contact
- Platform: MQL5 Community
- Profile: https://www.mql5.com/es/users/nique_372
- Articles: https://www.mql5.com/es/users/nique_372/publications
Roadmap
- Core arithmetic, bitwise ops, comparisons, schoolbook multiplication, standard GCD, byte/string conversion [Complete]
- Karatsuba multiplication for large operands [In progress]
PowMod(modular exponentiation) [Pending]IsProbablePrime(Miller-Rabin) [Pending]GdcExtendedRetX(extended GCD / modular inverse) [Pending]
Copyright © 2026 Niquel & Leo — TSN Ecosystem