<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Parrot - Mathematical Opcodes</title> <link rel="stylesheet" type="text/css" href="../../../resources/parrot.css" media="all"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <div id="wrapper"> <div id="header"> <a href="http://www.parrot.org"> <img border=0 src="../../../resources/parrot_logo.png" id="logo" alt="parrot"> </a> </div> <!-- "header" --> <div id="divider"></div> <div id="mainbody"> <div id="breadcrumb"> <a href="../../../html/index.html">Home</a> » <a href="../../../html/ops.html">Opcodes</a> » Mathematical Opcodes </div> <h1><a name="NAME" >NAME</a></h1> <p>math.ops - Mathematical Opcodes</p> <h1><a name="DESCRIPTION" >DESCRIPTION</a></h1> <p>Parrot's library of mathematical ops.</p> <p>To use this library of ops, add this directive to your PIR:</p> <pre> .loadlib 'math_ops'</pre> <dl> <dt><a name="rand(out_NUM)" ><b>rand</b>(out NUM)</a></dt> Set $1 to a random floating point number between 0 and 1, inclusive. <dt><a name="rand(out_INT)" ><b>rand</b>(out INT)</a></dt> Set $1 to a random integer between <code>[-2^31, 2^31)</code> . <dt><a name="rand(out_NUM,_in_NUM)" ><b>rand</b>(out NUM, in NUM)</a></dt> Set $1 to a random floating point number between 0 and and $2, inclusive. <dt><a name="rand(out_INT,_in_INT)" ><b>rand</b>(out INT, in INT)</a></dt> Set $1 to a integer between 0 and and $2, inclusive. <dt><a name="rand(out_NUM,_in_NUM,_in_NUM)" ><b>rand</b>(out NUM, in NUM, in NUM)</a></dt> Set $1 to a random floating point number between $2 and and $3, inclusive. <dt><a name="srand(in_NUM)" ><b>srand</b>(in NUM)</a></dt> Set the random number seed to $1. $1 is casted to an INTVAL. <dt><a name="srand(in_INT)" ><b>srand</b>(in INT)</a></dt> Set the random number seed to $1. <dt><a name="rand(out_INT,_in_INT,_in_INT)" ><b>rand</b>(out INT, in INT, in INT)</a></dt> Set $1 to a integer between $2 and and $3, inclusive.</dl> <h1><a name="COPYRIGHT" >COPYRIGHT</a></h1> <p>Copyright (C) 2001-2009, Parrot Foundation.</p> <h1><a name="LICENSE" >LICENSE</a></h1> <p>This program is free software. It is subject to the same license as the Parrot interpreter itself.</p> </div> <!-- "mainbody" --> <div id="divider"></div> <div id="footer"> Copyright © 2002-2009, Parrot Foundation. </div> </div> <!-- "wrapper" --> </body> </html>