n7 calculator helps kids and students to perform exact decimal arithmetic calculations.
The "n7 Arbitrary Precision Engine" is a high-performance mathematical toolkit that transforms an Arduino Zero into a scientific decimal coprocessor. Standard microcontrollers are limited by 32-bit floating-point math, which leads to significant rounding errors in complex calculations (typically after only 6-7 digits of precision). The n7 project utilizes the custom Num7 library to perform "Big Number" arithmetic, allowing students and engineers to calculate factorials, square roots, and financial percentages with virtually infinite precision, restricted only by the available RAM of the SAMD21 chip.
Technical Deep-Dive
- Arbitrary Precision Strategy:
- Beyond 32-Bits: Unlike standard variables, Num7 stores numerical data as dynamically allocated arrays or Strings. This prevents the "Overflow" errors common in standard Arduino math.
- Carry-Borrow Logic: Arithmetic operations (Addition, Subtraction, etc.) are performed using human-like digit-by-digit logic implemented in software. This ensures that $3.14159265...$ remains exact throughout the entire calculation chain.
- The DCS (Decimal Coprocessor Server) Concept:
- This project introduces a Distributed Computing model. A host PC running a Python script (
Arduino-n7-calc.py) sends complex mathematical strings over the Serial bridge. The Arduino Zero, acting as the "Server," performs the high-precision heavy lifting and returns the result as a text string.
- This project introduces a Distributed Computing model. A host PC running a Python script (
- SAMD21 Optimization:
- The Arduino Zero was chosen for its 48MHz 32-bit ARM Cortex-M0+ architecture. The increased clock speed and native 32-bit registers are essential for processing the large arrays of digits required for high-precision division (up to 32+ decimal places).
- Advanced Functionality:
- Financial Math: Includes specialized functions like
spoff(Spin-off/Tax removal) andpct(Percentage), allowing for precise economic modeling without the "pennies lost" rounding errors of standard calculators. - Scientific Constants: The engine contains pre-calculated values for Pi and e stored to 31 decimal places, serving as the benchmark for all high-precision trigonometry and growth calculations.
- Financial Math: Includes specialized functions like
Implementation & Command Interface
- The n7 CLI (Command Line Interface):
- Users interact with the system via the Serial Monitor (set to 115200 baud). The firmware uses a prefix-based parsing logic. Entering
n7 ! 5triggers the factorial function, whilen7 rnd 3.14159 2performs a precision-aware rounding to two decimal places.
- Users interact with the system via the Serial Monitor (set to 115200 baud). The firmware uses a prefix-based parsing logic. Entering
- Programming with Num7:
- The project encourages students to move beyond the Serial Monitor. By including the
<num7.h>library, developers can integrate high-precision variables directly into clinical instruments, data loggers, or robotics PID loops where standard float resolution is insufficient.
- The project encourages students to move beyond the Serial Monitor. By including the
- Rounding and Formatting:
- The library offers multiple rounding modes:
rnd(standard),rndc(ceiling), andrndf(floor), giving the user complete control over the significant figures of the output.
- The library offers multiple rounding modes:
- Bitwise & Base Conversion:
- The
bitscommand allows for instant conversion between high-precision decimals and their Binary or Hexadecimal counterparts, making it a valuable tool for computer science students studying memory addressing and data structures.
- The
In Arduino IDE2 open n7_ZERO.ino SKETCH, click on library icon, look for num7 library and install it as shown in the following image:

Then upload the sketch, set serial monitor to 115200 baud and input n7 + 5 6 as follows:

Press <enter> key and you'll see Arduino exact calculation result.
To perform a subtraction like 3.14 - 2.72 your input will be as follows:

To perform a floating point multiplication like 3.14 x 2.72 your input will be as follows:

and for division of 3.14 and 2.72 input: n7 : 3.14 2.72 as follows:

To perform remainder operation input n7 mod 10.0 4.0 (postfix .0 after integers) as follows:

To standard round input : n7 rnd 1.1544117647058823529411764705882352941176 2 and you will get 1.15 with 2 digits as follows:

To perform 5 factorial input n7 ! 5:

n7 can also be run from command line interface (CLI) with the client py Arduino-n7-calc.py using Arduino as DCS (Decimal Coprocessor Server) as follows:


Many other arithmetic operations possible are the following:
addition: n7 + 2 3.5 #5.5
addition: n7 + 2 3.5 4.5 #10.0
subtraction: n7 - 2 3.5 #-1.5
subtraction: n7 - 2 3.5 4.5 #-6.0
multiplication: n7 x 2 3.5 4.5 #31.5
multiplication: n7 X 2 3.5 4.5 #31.5
multiplication: n7 '*' 2 3.5 4 #28.0
division: n7 / 120 2.0 5 #12.0
division: n7 / 2.5 3.5 #0.7142857142857142857142857142857142857142
division: n7 : 2.5 3.5 #0.7142857142857142857142857142857142857142
remainder: n7 % 17.0 10 4 #3.0
factorial: n7 ! 5 #120.0
absolute: n7 abs -5.0 #5.0
addition: n7 add 3.0 5.5 #8.5
subtraction: n7 sub 3.0 5.5 #-2.5
multiplication: n7 mul 3.0 5.5 #16.5
division: n7 div 3.0 5.5 6 #0.545454
remainder: n7 mod 10.0 7.0 #3.0
inverse: n7 inv 3.0 6 #0.333333
square root: n7 sqr 2.0 6 #1.414213
square: n7 x2 5.0 #25.0
cube: n7 x3 5.0 #125.0
power: n7 xy 10.5 3.0 #1157.625
power: n7 ^ 10.5 3.0 #1157.625
10y: n7 10y 3.0 #1000.0
2y: n7 2y 32.0 #4294967296.0
ey: n7 ey 1.0 #2.7182818284590452353602874713527
factorial: n7 fact 5 #120.0
10x: n7 10x 5.25 #52.5
100x: n7 100x 5.25 #525.0
1000x: n7 1000x 5.25 #5250.0
10div: n7 10div 5.25 #0.525
100div: n7 100div 5.25 #0.0525
1000div: n7 1000div 5.25 #0.00525
shift: n7 shift 5.25 3.0 #5250.0
shift: n7 shift 5.25 -3.0 #0.00525
percentage: n7 pct 3.725 150.0 #5.5875
perthousand: n7 pth 2.0 24_000.0 #48.0
spin-off: n7 spoff 22.0 1_299.0 #1064.75409836065573770491803278688524
spin-on: n7 rnd $(n7 spon 22.0 1_064.75) #1299.0
rnd: n7 rnd 3.141592654 4 #3.1416
rndb: n7 rndb 3.14159265 7 #3.1415926
rndc: n7 rndc 3.141592654 #4.0
rndf: n7 rndf 3.74 #3.0
sum: n7 sum 3.74 0.26 4 2.0 #10.0
min: n7 min 3.74 0.26 4 2.0 #0.26
max: n7 max 3.74 0.26 4 2.0 #4.0
mean: n7 mean 3.74 0.26 4 2.0 #2.5
e: n7 e #2.7182818284590452353602874713527
pi: n7 pi #3.1415926535897932384626433832795
exp: n7 exp 200.0e-5 #200.0e-5
scientific: n7 sci 200.0e-5 #2.0e-3
bits: n7 bits 10.0 #1010
bits: n7 bits 65535.0 0 #FFFF
gt: n7 gt -5.0 -4.0 #0
ge: n7 ge -6.0 -6.0 #1
lt: n7 lt -5.0 0.0 #1
le: n7 le -5.0 -5.0 #1
eq: n7 eq -5.0 0.0 #0
ne: n7 ne -5.0 0.0 #1
is_zero: n7 is_zero 0.0 #1
is_pos: n7 is_pos 1.0 #1
is_neg: n7 is_neg -1.0 #1
is_even: n7 is_even 3.0 #0
is_odd: n7 is_odd 2.0 #0
is_int: n7 is_int -2.1 #0
is_prime: n7 is_prime +3.0 #1
Elevate your school homework from standard math to exact engineering with the n7 Decimal Coprocessor.