NatArithmetic.borg
NatArithmetic.borg
{
Add()::
(-0.0 = 0.0) &
((+ 2) = 2) &
((+ 2.5) = 2.5) &
(1 + 2 = 3) &
(1.5 + 6 = 7.5) &
(1.5 + 0.5 = 2);
Sub()::
({a:2;
b:1-3;
- a = b}) &
(1 - 0.5 = 0.5);
Mul()::
(1 * 5 = 5) &
(2 * 5 = 10) &
(0 * 5 = 0) &
(0.5 * 10 = 5) &
(0.5 * 0.5 = 0.25);
Div():: (1/5 = 0.2) &
(4.5/1.5 = 3) &
(-1/5= -0.2);
Idv():: (11//2 = 5);
Rem():: (11\\2 = 1);
Pow():: (0^1 = 0) &
(0^0 = 1) &
(2^0 = 1) &
(2^5 = 32) &
(2^6 = 64) &
(2^7 = 128) &
(2^8 = 256) &
(2^9 = 512) &
(2^10 = 1024) &
(2^11 = 2048) &
(2^12 = 4096) &
(2^13 = 8192) &
(2^14 = 16384) &
(2^15 = 32768) &
(2^16 = 65536) &
(2^17 = 131072) &
(2^18 = 262144) &
(2^19 = 524288);
ITEM("add",Add,1);
ITEM("sub",Sub,1);
ITEM("mul",Mul,1);
ITEM("div",Div,1);
ITEM("intdiv",Idv,1);
ITEM("remainder",Rem,1);
ITEM("power",Pow,1)
}