[t][cage] Remove PGE-dependence from t/op/inf_nan.t since it is part of 'make coretest'
[parrot.git] / src / dynoplibs / math.ops
blob1d8bfc2248f872be8bb880760603de858f84b298
1 /*
2  * $Id$
3 ** math.ops
4 */
6 BEGIN_OPS_PREAMBLE
8 #include <math.h>
10 END_OPS_PREAMBLE
12 =head1 NAME
14 math.ops - Mathematical Opcodes
16 =cut
18 =head1 DESCRIPTION
20 Parrot's library of mathematical ops.
22 To use this library of ops, add this directive to your PIR:
24  .loadlib 'math_ops'
26 =cut
28 =over
30 =item B<rand>(out NUM)
32 Set $1 to a random floating point number between 0 and 1, inclusive.
34 =cut
36 inline op rand(out NUM) {
37   $1 = Parrot_float_rand(0);
40 =item B<rand>(out INT)
42 Set $1 to a random integer between C<[-2^31, 2^31)> .
44 =cut
46 inline op rand(out INT) {
47   $1 = Parrot_int_rand(0);
50 =item B<rand>(out NUM, in NUM)
52 Set $1 to a random floating point number between 0 and and $2, inclusive.
54 =cut
56 inline op rand(out NUM, in NUM) {
57   $1 = $2 * Parrot_float_rand(0);
60 =item B<rand>(out INT, in INT)
62 Set $1 to a integer between 0 and and $2, inclusive.
64 =cut
66 inline op rand(out INT, in INT) {
67   $1 = Parrot_range_rand(0, $2, 0);
70 =item B<rand>(out NUM, in NUM, in NUM)
72 Set $1 to a random floating point number between $2 and and $3, inclusive.
74 =cut
76 inline op rand(out NUM, in NUM, in NUM) {
77   $1 = $2 + ($3 - $2) * Parrot_float_rand(0);
80 =item B<srand>(in NUM)
82 Set the random number seed to $1. $1 is casted to an INTVAL.
84 =cut
86 inline op srand(in NUM) {
87     Parrot_srand((INTVAL)$1);
90 =item B<srand>(in INT)
92 Set the random number seed to $1.
94 =cut
96 inline op srand(in INT) {
97     Parrot_srand((INTVAL)$1);
100 =item B<rand>(out INT, in INT, in INT)
102 Set $1 to a integer between $2 and and $3, inclusive.
104 =cut
106 inline op rand(out INT, in INT, in INT) {
107   $1 = Parrot_range_rand($2, $3, 0);
110 =back
112 =head1 COPYRIGHT
114 Copyright (C) 2001-2009, Parrot Foundation.
116 =head1 LICENSE
118 This program is free software. It is subject to the same license
119 as the Parrot interpreter itself.
121 =cut
125  * Local variables:
126  *   c-file-style: "parrot"
127  * End:
128  * vim: expandtab shiftwidth=4:
129  */