hcl/t/test-bi.hcl
hyung-hwan 2d9f5b51ad added sys.time, sys.random, sys.srandom.
removed test-bi.sh
wrote a simple bigint test program into test-bi.hcl
2019-04-17 03:46:39 +00:00

37 lines
890 B
HCL

## test big integer operations
## hcl --log /dev/null,warn+ test-bi.hcl
(sys.srandom (sys.time))
(set count 0)
(while true
(printf "%O\r" count)
(set count (+ count 1))
(set limit (rem (sys.random) 30))
(set dividend (sys.random))
(set i 1)
(while (< i limit)
(set dividend (bit-or (bit-shift dividend 30) (sys.random)))
(set i (+ i 1))
)
(set limit (rem (sys.random) 30))
(set divisor (sys.random))
(set i 1)
(while (< i limit)
(set divisor (bit-or (bit-shift divisor 30) (sys.random)))
(set i (+ i 1))
)
(set quotient (/ dividend divisor))
(set remainder (rem dividend divisor))
(set derived_dividend (+ (* quotient divisor) remainder))
(if (/= dividend derived_dividend)
(printf ">> dividend %O\n>> divisor %O\n>> quotient %O\n>> remainder %O\n>> derived_dividend %O\n"
dividend divisor quotient remainder derived_dividend)
(break)
)
)
(printf "\n")