// math-lib.l1com // math library demo // #include <math-const.l1h> #include <intr.l1h> (main func) (set int64 1 zero 0) (set int64 1 randstart 2003) (set int64 1 random 0) (set int64 1 digits 3) (set int64 1 numstr_len 30) (set int64 1 not_num 0) (set int64 1 not_ret) (set string 30 numstr "") (zero :math_init call) (loadreg) (randstart :math_randinit call) (loadreg) (:math_randint call) (random stpopi) (loadreg) print_i (random) print_n print_d (m_pi@math) print_n // round pi to "digits" (3) digits and store number in string (m_pi@math digits numstraddr numstr_len :double_rounded_string call) (loadreg) print_s (numstr) print_n (not_num :math_not call) (not_ret stpopi) (loadreg) print_i (not_ret) print_n // close module free_mod (zero) exit (zero) (funcend) #include <math-lib.l1h>
This demo program prints out:
$ l1vm lib/math-lib -q 3368910609462220170 3.1415926536 3.142 1
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
What do you want to know?
Are you sure? yes | no