403 lines
18 KiB
HTML
403 lines
18 KiB
HTML
|
<?xml version="1.0" encoding="utf-8"?>
|
|||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|||
|
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="PBASIC Language Reference" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
|||
|
<head><title>PBASIC Operators</title>
|
|||
|
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
|||
|
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
|||
|
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
|||
|
</script>
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="AlphaRef.htm">PBASIC Language Reference</a><span class="MCBreadcrumbsDivider"> > </span><span class="MCBreadcrumbs">PBASIC Operators</span>
|
|||
|
</div>
|
|||
|
<h1>PBASIC Operators</h1>
|
|||
|
<p>
|
|||
|
<img src="../../graphics/pgm_icon1.gif" border="0" alt="" />
|
|||
|
<img src="../../graphics/pgm_icon2.gif" border="0" alt="" />
|
|||
|
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="" />
|
|||
|
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="" />
|
|||
|
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="" />
|
|||
|
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="" />
|
|||
|
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="" />
|
|||
|
</p>
|
|||
|
<p> </p>
|
|||
|
<p class="PlainText">(See <a href="OpsPrecedence.htm" target="" title="" alt="" class="MCXref_0">Operator Precedence</a> for details of the sequence in which expression operators are evaluated.)</p>
|
|||
|
<h2>Binary and Unary Operators</h2>
|
|||
|
<p class="PlainText">There are two types of operators in PBASIC, binary operators which require two arguments (such as the addition operator in 2 + 3) and unary operators which require one argument (such as the negate operator in -5). All the PBASIC operators are shown below, grouped under binary operators or unary operators. Click on any operator to see a full description on the Binary Operator or Unary Operator page.</p>
|
|||
|
<h2>Notes about the 16-bit workspace</h2>
|
|||
|
<p class="PlainText">Many of the operator descriptions will say something like "computes (some function) of a 16-bit number." This does not mean that the operator does not work on smaller byte or nibble values, but rather that the computation is done in a 16-bit workspace. If the value is smaller than 16 bits, the BASIC Stamp pads it with leading 0s to make a 16-bit value. If the 16-bit result of a calculation is to be packed into a smaller variable, the higher-order bits are discarded (truncated).</p>
|
|||
|
<table cellpadding="4" cellspacing="0" border="0">
|
|||
|
<tr>
|
|||
|
<td colspan="5"><a href="Ops_bi.htm" target="" title="" alt="" class="MCXref_0">Binary Operators</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td width="10"> </td>
|
|||
|
<td width="55">• <a href="Ops_bi.htm#addition">+</a></td>
|
|||
|
<td width="90" align="absmiddle">
|
|||
|
<img src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td width="15"> </td>
|
|||
|
<td><a href="Ops_bi.htm#addition">Addition</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#subtraction">-</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#subtraction">Subtraction</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#multiply">*</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#multiply">Multiplication</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#multi-high">**</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#multi-high">Multiply High (Return Upper 16 Bits)</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#multi-mid">*/</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#multi-mid">Multiply Middle (Return Middle 16 Bits)</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#divide">/</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#divide">Division</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#modulus">//</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#modulus">Modulus (Remainder of Division)</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#limit-min">MIN</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#limit-min">Limit a Value to Specified Low</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#limit-max">MAX</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#limit-max">Limit a Value to Specified High</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#digit">DIG</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#digit">Return Specified Digit of Number</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#reverse">REV</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#reverse">Reverse Specified Number of Bits</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#shfitleft"><<</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#shfitleft">Shift Bits Left by Specified Amount</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#shiftright">>></a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#shiftright">Shift Bits Right by Specified Amount</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#bitwiseand">&</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#bitwiseand">Bitwise AND</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#bitwiseor">|</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#bitwiseor">Bitwise OR</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#bitwisexor">^</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#bitwisexor">Bitwise XOR</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#andnot">&/</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_1.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#andnot">Bitwise AND NOT</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#ornot">|/</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_1.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#ornot">Bitwise OR NOT</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#xornot">^/</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_1.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#xornot">Bitwise XOR NOT</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#and">AND</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#and">Logical AND</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#or">OR</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#or">Logical OR</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#xor">XOR</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#xor">Logical XOR</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#arctan">ATN</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#arctan">Return Arctangent of Vector</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_bi.htm#hypot">HYP</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_bi.htm#hypot">Return Hypotenuse</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td colspan="5"> </td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td colspan="5"><a href="Ops_uni.htm" target="" title="" alt="" class="MCXref_0">Unary Operators</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_uni.htm#absval">ABS</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_uni.htm#absval">Return Absolute Value</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_uni.htm#negative">-</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_all.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_uni.htm#negative">Negate</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_uni.htm#invert">~</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_uni.htm#invert">Bitwise Inverse</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_uni.htm#dcd">DCD</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_uni.htm#dcd">2<sup>n</sup>-power Decoder</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_uni.htm#ncd">NCD</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_uni.htm#ncd">Priority Encoder of 16-bit Value</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_uni.htm#sine">SIN</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_uni.htm#sine">Return (signed) Sine Value of Angle</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_uni.htm#cosine">COS</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_uni.htm#cosine">Return (signed) Cosine Value of Angle</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_uni.htm#square">SQR</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_uni.htm#square">Return Square Root of value</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
<td>• <a href="Ops_uni.htm#not">NOT</a></td>
|
|||
|
<td>
|
|||
|
<img align="absmiddle" src="../../graphics/stamp_2family.gif" />
|
|||
|
</td>
|
|||
|
<td> </td>
|
|||
|
<td><a href="Ops_uni.htm#not">Logical NOT</a>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<p> </p>
|
|||
|
<div class="Col2">
|
|||
|
<div class="MasterFoot">
|
|||
|
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="Col2">
|
|||
|
<div class="MasterFoot">
|
|||
|
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
|||
|
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
|||
|
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<script type="text/javascript">/* <![CDATA[ */
|
|||
|
|
|||
|
var _gaq = _gaq || [];
|
|||
|
_gaq.push(['_setAccount', 'UA-285614-1']);
|
|||
|
_gaq.push(['_trackPageview']);
|
|||
|
|
|||
|
(function() {
|
|||
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|||
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|||
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|||
|
})();
|
|||
|
|
|||
|
/* ]]> */</script>
|
|||
|
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
|||
|
</script>
|
|||
|
</body>
|
|||
|
</html>
|