5 src/builtins/any_num.pir - C<Num>-like functions and methods for C<Any>
9 This file implements the methods and functions of C<Any> that
10 are most closely associated with the C<Num> class or role.
11 We place them here instead of F<src/classes/Any.pir> to keep
12 the size of that file down and to emphasize their generic,
22 .sub 'onload' :anon :init :load
23 $P0 = get_hll_namespace ['Any']
24 '!EXPORT'('abs cis polar sqrt truncate int unpolar', 'from'=>$P0)
26 ## pre-seed a random number generator
28 set_hll_global ['Any'], '$!random', $P0
38 .sub 'abs' :method :multi(_)
50 .sub 'cis' :method :multi(_)
51 .return 'unpolar'(1.0, self)
60 .sub 'polar' :method :multi(_)
62 .return 'list'($N0, 0)
73 ## 0-argument test, RT#56366
75 die "too many arguments passed - 0 params expected"
77 $P0 = get_hll_global ['Any'], '$!random'
85 $P0 = get_hll_global ['Any'], '$!random'
97 .sub 'sqrt' :method :multi(_)
110 .param num seed :optional
111 .param int has_seed :opt_flag
112 if has_seed goto have_seed
115 $P0 = get_hll_global ['Any'], '$!random'
125 $P0 = get_hll_global ['Any'], '$!random'
138 .sub 'truncate' :method :multi(_)
140 if $N0 == 0 goto done
141 if $N0 < 0 goto num_ceil
151 .sub 'int' :method :multi(_)
152 .return self.'truncate'()
155 =item unpolar($angle)
159 .sub 'unpolar' :method
164 result = new 'Complex'
183 # vim: expandtab shiftwidth=4 ft=pir: