RPN calculator for multi-precision finite arithmetic
Table of Contents
1. Task1
Create a calculator for multi-precision finite arithmetic <Zi; +, *> (8 digits) for four operations (+, -, *, ÷) based on single-precision finite arithmetic, where the "+1" rule is defined and the properties of commutativity (+, *), associativity (+, *), and distributivity of * over + are satisfied; an additive identity "a" and a multiplicative identity "b" are defined; and the following property holds: for (∀x) x*a=a. Additionally, you can implement exponentiation, as well as the search for GCD and LCM for two numbers.
| x | = | a | b | c | d | e | f | g | h |
| x + b | = | b | d | h | c | f | a | e | g |
2. Documentation
The exported report can be found at this link.
3. Showcase
> jsadh
[-] ERROR: input doesn't match regexp `^\s*([+-][a-h]{1,8}|nop|dup|del|clr|swp|neg|add|mul|sub|div|mod|inc|dec|pow|gcd|lcm)\s*$'
> nop
> +f
f
>
f
f
> dup
f
f
f
> add
f
be
> sub
-f
> neg
f
> -a
f
a
> div
[*] INFO: division by zero
[*] INFO: operation resulted in empty set
> +a
a
>
a
a
> div
[*] INFO: dividing zero by zero
[*] INFO: operation result is a range: [-ffffffff; ffffffff]
> +ffffffff
ffffffff
>
ffffffff
ffffffff
> mul
[-] ERROR: operation has overflown
> +ghf
ghf
> -fe
ghf
-fe
> mod
eb
> +ghf
eb
ghf
> -fe
eb
ghf
-fe
> div
eb
-g
> -fe
eb
-g
-fe
> mul
eb
hee
> add
ghf
> inc
gga
>
ggb
>
ggd
>
ggc
> dec
ggd
>
ggb
>
gga
> del
>
[*] INFO: stack is already empty
> clr
[*] INFO: stack is already empty
> +d
d
> +h
d
h
> pow
da
> del
> +e
e
> +h
e
h
> gcd
d
> +c
d
c
> lcm
e
> +f
e
f
> swp
f
e
> clr
> ^Cinterrupt
4. Unlicense
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to https://unlicense.org/
Footnotes:
Original text:
Сформировать калькулятор «большой» конечной арифметики <Zi; +, *> (8 разрядов) для четырех действий (+, -, *, ÷)= на основе «малой» конечной арифметики, где задано правило «+1» и выполняются свойства коммутативности (+, *), ассоциативности (+, *), дистрибутивности * относительно +, заданы аддитивная единица «a» и мультипликативная единица «b», а также выполняется свойство: для (∀х) х*a=a. Дополнительно можно реализовать возведение в степень, поиск НОД и НОК для двух чисел.
Table 2: Правило «+1»: x = a b c d e f g h x + b = b d h c f a e g
Created: 2026-11-07 Sat 05:13
