prog8/examples/arithmetic/builtins.p8

765 lines
16 KiB
Plaintext
Raw Normal View History

2020-11-07 00:08:56 +00:00
%import textio
%import floats
%import string
2020-11-07 00:08:56 +00:00
%import syslib
%import test_stack
2020-11-07 00:08:56 +00:00
%zeropage basicsafe
main {
sub start() {
rotations()
integers()
floatingpoint()
test_stack.test()
2020-11-07 00:08:56 +00:00
}
sub rotations() {
ubyte[] ubarr = [%11000111]
uword[] uwarr = [%1100111110101010]
repeat(10) {
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
}
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
uwarr[0] = %1100111110101010
ror(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
sys.clear_carry()
2020-11-07 00:08:56 +00:00
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(uwarr[0])
txt.print_uwbin(uwarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(ubarr[0])
txt.print_ubbin(ubarr[0], true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
&ubyte membyte = $c000
uword addr = $c000
@(addr) = %10110101
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
rol(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
@(addr) = %10110101
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
sys.set_carry()
2020-11-07 00:08:56 +00:00
ror(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
@(addr) = %10110101
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
rol2(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
@(addr) = %10110101
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ror2(@(addr))
txt.print_ubbin(@(addr), true)
2021-01-08 15:56:17 +00:00
txt.nl()
txt.nl()
2020-11-07 00:08:56 +00:00
test_stack.test()
2020-11-07 00:08:56 +00:00
}
sub integers() {
ubyte[] ubarr = [1,2,3,4,5,0,4,3,2,1, 255, 255, 255]
byte[] barr = [1,2,3,4,5,-4,0,-3,2,1, -128, -128, -127]
uword[] uwarr = [100,200,300,400,0,500,400,300,200,100]
word[] warr = [100,200,300,400,500,0,-400,-300,200,100,-99, -4096]
ubyte zero=0
ubyte ub
ubyte ub2
byte bb
uword uw
word ww
repeat(20) {
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
}
ub = sys.read_flags()
2020-11-07 00:08:56 +00:00
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
ub = zero+sys.read_flags()*1+zero
2020-11-07 00:08:56 +00:00
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = rnd()
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+rnd()*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = rndw()
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = zero+rndw()*1+zero
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = 50000
ub = sqrt16(uw)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+sqrt16(uw)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = -100
bb = sgn(bb)
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = -100
bb = zero+sgn(bb)*1+zero
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = 100
bb = sgn(ub)
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = 100
bb = zero+sgn(ub)*1+zero
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = -1000
bb = sgn(ww)
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = zero+sgn(ww)*1+zero
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = 1000
bb = sgn(uw)
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = zero+sgn(uw)*1+zero
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = 0
uw = sin16u(ub)
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = zero+sin16u(ub)*1+zero
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = 0
uw = cos16u(ub)
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = zero+cos16u(ub)*1+zero
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = 0
ww = sin16(ub)
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = zero+sin16(ub)*1+zero
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = 0
ww = cos16(ub)
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = 0
ww = zero+cos16(ub)*1+zero
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub2 = 0
ub = sin8u(ub2)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+sin8u(ub2)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub2 = 0
ub = cos8u(ub2)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+cos8u(ub2)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub2 = 0
bb = sin8(ub2)
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = zero+sin8(ub2)*1+zero
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub2 = 0
bb = cos8(ub2)
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = zero+cos8(ub2)*1+zero
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = -100
bb = abs(bb)
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = -100
bb = zero+abs(bb)*1+zero
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = -1000
ww = abs(ww)
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = -1000
ww = zero+abs(ww)*1+zero
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = min(ubarr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+min(ubarr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = min(barr)
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = zero+min(barr)*1+zero
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = min(uwarr)
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = zero+min(uwarr)*1+zero
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = min(warr)
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = zero+min(warr)*1+zero
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = max(ubarr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+max(ubarr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = max(barr)
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
bb = zero+max(barr)*1+zero
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = max(uwarr)
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = zero+max(uwarr)*1+zero
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = max(warr)
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = zero+max(warr)*1+zero
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = any(ubarr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+any(ubarr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = any(barr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+any(barr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = any(uwarr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+any(uwarr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = any(warr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+any(warr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = all(ubarr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+all(ubarr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = all(barr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+all(barr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = all(uwarr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+all(uwarr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = all(warr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+all(warr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = sum(ubarr)
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = zero+sum(ubarr)*1+zero
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = sum(barr)
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = zero+sum(barr)*1+zero
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = sum(uwarr)
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
uw = zero+sum(uwarr)*1+zero
txt.print_uw(uw)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = sum(warr)
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ww = zero+sum(warr)*1+zero
txt.print_w(ww)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
sort(ubarr)
sort(barr)
sort(uwarr)
sort(warr)
reverse(ubarr)
reverse(barr)
reverse(uwarr)
reverse(warr)
test_stack.test()
2020-11-07 00:08:56 +00:00
}
sub floatingpoint() {
ubyte[] barr = [1,2,3,4,5,0,4,3,2,1]
float[] flarr = [1.1, 2.2, 3.3, 0.0, -9.9, 5.5, 4.4]
ubyte zero=0
ubyte ub
byte bb
uword uw
float fl
float fzero=0.0
fl = -9.9
fl = abs(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = fzero+abs(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 9.9
fl = atan(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 9.9
fl = fzero+atan(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = ceil(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = fzero+ceil(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = cos(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = fzero+cos(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = sin(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = fzero+sin(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 9.9
fl = tan(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 9.9
fl = fzero+tan(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 3.1415927
fl = deg(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 3.1415927
fl = fzero+deg(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 90
fl = rad(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 90
fl = fzero+rad(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = floor(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = fzero+floor(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 3.1415927
fl = ln(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 3.1415927
fl = fzero+ln(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 3.1415927
fl = log2(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 3.1415927
fl = fzero+log2(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = round(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
fl = fzero+round(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
bb = sgn(fl)
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = -9.9
bb = zero+sgn(fl)*1+zero
txt.print_b(bb)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 3.1415927
fl = sqrt(fl)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = 3.1415927
fl = fzero+sqrt(fl)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = rndf()
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = fzero+rndf()*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
swap(fl, fzero)
swap(fzero, fl)
ub = any(flarr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+any(flarr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = all(flarr)
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
ub = zero+all(flarr)*1+zero
txt.print_ub(ub)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
reverse(flarr)
for ub in 0 to len(flarr)-1 {
floats.print_f(flarr[ub])
txt.chrout(',')
}
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = max(flarr)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = fzero+max(flarr)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = min(flarr)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = fzero+min(flarr)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = sum(flarr)
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
fl = fzero+sum(flarr)*1.0+fzero
floats.print_f(fl)
2021-01-08 15:56:17 +00:00
txt.nl()
2020-11-07 00:08:56 +00:00
test_stack.test()
2020-11-07 00:08:56 +00:00
}
}