mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-27 18:13:52 +01:00
262 lines
9.8 KiB
HTML
262 lines
9.8 KiB
HTML
|
|
<!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" lang="English">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>Netscript Operators — Bitburner 1.0 documentation</title>
|
|
<link rel="stylesheet" href="_static/agogo.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: './',
|
|
VERSION: '1.0',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true,
|
|
SOURCELINK_SUFFIX: '.txt'
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
|
<link rel="index" title="Index" href="genindex.html" />
|
|
<link rel="search" title="Search" href="search.html" />
|
|
<link rel="next" title="Netscript Loops and Conditionals" href="netscriptloopsandconditionals.html" />
|
|
<link rel="prev" title="Netscript Data Types and Variables" href="netscriptdatatypes.html" />
|
|
</head>
|
|
<body>
|
|
<div class="header-wrapper" role="banner">
|
|
<div class="header">
|
|
<div class="headertitle"><a
|
|
href="index.html">Bitburner 1.0 documentation</a></div>
|
|
<div class="rel" role="navigation" aria-label="related navigation">
|
|
<a href="netscriptdatatypes.html" title="Netscript Data Types and Variables"
|
|
accesskey="P">previous</a> |
|
|
<a href="netscriptloopsandconditionals.html" title="Netscript Loops and Conditionals"
|
|
accesskey="N">next</a> |
|
|
<a href="genindex.html" title="General Index"
|
|
accesskey="I">index</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="content-wrapper">
|
|
<div class="content">
|
|
<div class="document">
|
|
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body" role="main">
|
|
|
|
<div class="section" id="netscript-operators">
|
|
<h1>Netscript Operators<a class="headerlink" href="#netscript-operators" title="Permalink to this headline">¶</a></h1>
|
|
<div class="section" id="operators">
|
|
<h2>Operators<a class="headerlink" href="#operators" title="Permalink to this headline">¶</a></h2>
|
|
<div class="section" id="binary-operators">
|
|
<h3>Binary Operators<a class="headerlink" href="#binary-operators" title="Permalink to this headline">¶</a></h3>
|
|
<p>Binary operators require two operands and produce a result based on their values. In general, binary
|
|
operators do not change the value of the operands.</p>
|
|
<table border="1" class="docutils">
|
|
<colgroup>
|
|
<col width="11%" />
|
|
<col width="27%" />
|
|
<col width="62%" />
|
|
</colgroup>
|
|
<thead valign="bottom">
|
|
<tr class="row-odd"><th class="head">Operator</th>
|
|
<th class="head">Name</th>
|
|
<th class="head">Example/Comments</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody valign="top">
|
|
<tr class="row-even"><td>=</td>
|
|
<td>Assignment</td>
|
|
<td>i = 5 would assign the value 5 to the variable i</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>+</td>
|
|
<td>Addition</td>
|
|
<td>5 + 12 would return 17</td>
|
|
</tr>
|
|
<tr class="row-even"><td>-</td>
|
|
<td>Subtraction</td>
|
|
<td>20 - 8 would return 12</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>*</td>
|
|
<td>Multiplication</td>
|
|
<td>4 * 5 would return 20</td>
|
|
</tr>
|
|
<tr class="row-even"><td>/</td>
|
|
<td>Division</td>
|
|
<td>50 / 10 would return 5</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>%</td>
|
|
<td>Modulo</td>
|
|
<td>50 % 9 would return 5</td>
|
|
</tr>
|
|
<tr class="row-even"><td>&&</td>
|
|
<td>Logical AND</td>
|
|
<td>true && false would return false</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>||</td>
|
|
<td>Logical OR</td>
|
|
<td>true || false would return true</td>
|
|
</tr>
|
|
<tr class="row-even"><td><</td>
|
|
<td>Less than</td>
|
|
<td>4 < 5 would return true</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>></td>
|
|
<td>Greater than</td>
|
|
<td>4 > 5 would return false</td>
|
|
</tr>
|
|
<tr class="row-even"><td><=</td>
|
|
<td>Less than or equal to</td>
|
|
<td>5 <= 5 would return true</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>>=</td>
|
|
<td>Greater than or equal to</td>
|
|
<td>5 >= 4 would return true</td>
|
|
</tr>
|
|
<tr class="row-even"><td>==</td>
|
|
<td>Equality</td>
|
|
<td>1 == 1 would return true</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>!=</td>
|
|
<td>Inequality</td>
|
|
<td>4 != 5 would return true</td>
|
|
</tr>
|
|
<tr class="row-even"><td>===</td>
|
|
<td>Strict equality</td>
|
|
<td>1 === "1" would return false</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>!==</td>
|
|
<td>Strict inequality</td>
|
|
<td>1 !== "1" would return true</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="section" id="unary-operators">
|
|
<h3>Unary Operators<a class="headerlink" href="#unary-operators" title="Permalink to this headline">¶</a></h3>
|
|
<p>Unary operators require only a single operand and produce a result based on their values. Some unary operators will
|
|
change the value of their operands. For example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|
<span class="o">++</span><span class="n">i</span><span class="p">;</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Running the pre-increment unary operator (++) in the code above changes the value of the variable i.</p>
|
|
<table border="1" class="docutils">
|
|
<colgroup>
|
|
<col width="11%" />
|
|
<col width="20%" />
|
|
<col width="69%" />
|
|
</colgroup>
|
|
<thead valign="bottom">
|
|
<tr class="row-odd"><th class="head">Operator</th>
|
|
<th class="head">Name</th>
|
|
<th class="head">Example/comments</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody valign="top">
|
|
<tr class="row-even"><td>!</td>
|
|
<td>Logical NOT operator</td>
|
|
<td>!true would return false, and !false would return true. Does not change operand's value</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>-</td>
|
|
<td>Negation</td>
|
|
<td>Negates a number. Only works for numerics. Does not change operand's value</td>
|
|
</tr>
|
|
<tr class="row-even"><td>++</td>
|
|
<td>Pre-increment</td>
|
|
<td>++i or i++. WARNING: This only pre-increments, even if you put i++. Changes operand's value</td>
|
|
</tr>
|
|
<tr class="row-odd"><td>--</td>
|
|
<td>Pre-decrement</td>
|
|
<td>--i or i--. WARNING: This only pre-decrements, even if you put i--. Changes operand's value</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sidebar">
|
|
<h3>Table Of Contents</h3>
|
|
<p class="caption"><span class="caption-text">Contents:</span></p>
|
|
<ul class="current">
|
|
<li class="toctree-l1 current"><a class="reference internal" href="netscript.html"> Netscript</a><ul class="current">
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptdatatypes.html"> Data Types and Variables</a></li>
|
|
<li class="toctree-l2 current"><a class="current reference internal" href="#"> Operators</a><ul>
|
|
<li class="toctree-l3"><a class="reference internal" href="#operators">Operators</a><ul>
|
|
<li class="toctree-l4"><a class="reference internal" href="#binary-operators">Binary Operators</a></li>
|
|
<li class="toctree-l4"><a class="reference internal" href="#unary-operators">Unary Operators</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptadvancedfunctions.html"> Advanced Functions</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="shortcuts.html"> Keyboard Shortcuts</a></li>
|
|
</ul>
|
|
|
|
<div role="search">
|
|
<h3 style="margin-top: 1.5em;">Search</h3>
|
|
<form class="search" action="search.html" method="get">
|
|
<input type="text" name="q" />
|
|
<input type="submit" value="Go" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer-wrapper">
|
|
<div class="footer">
|
|
<div class="left">
|
|
<div role="navigation" aria-label="related navigaton">
|
|
<a href="netscriptdatatypes.html" title="Netscript Data Types and Variables"
|
|
>previous</a> |
|
|
<a href="netscriptloopsandconditionals.html" title="Netscript Loops and Conditionals"
|
|
>next</a> |
|
|
<a href="genindex.html" title="General Index"
|
|
>index</a>
|
|
</div>
|
|
<div role="note" aria-label="source link">
|
|
<br/>
|
|
<a href="_sources/netscriptoperators.rst.txt"
|
|
rel="nofollow">Show Source</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="right">
|
|
|
|
<div class="footer" role="contentinfo">
|
|
© Copyright 2017, Bitburner.
|
|
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.4.
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |