1
0
mirror of https://github.com/elua/elua.git synced 2025-01-08 20:56:17 +08:00
elua/doc/en/bit_doc.html

110 lines
3.5 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Language" content="en-us">
<title>Product</title><link rel="stylesheet" type="text/css" href="./style.css"></head>
<body bgcolor="#ffffff">
<h3><a name="over"></a>bit</h3>This is ugly but acording to Roberto, this is what Lua 5.2+ will have.
<p class="MsoNormal" style="font-family: Verdana;">
The problem is that <b>not </b>and <b>and</b> are Lua reserved words and cannot be used as table indexes.<br>
</p>
<p class="MsoNormal" style="font-family: Verdana;">
We could add .rot and .rotc to these :)
</p>
<p class="MsoNormal" style="font-family: Verdana;">
<br>
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res = bit.bnot( value ): unary negation
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res = bit.band( v1, v2, ... ): <b>bitwise </b>"and"
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res = bit.bor( v1, v2, ... ):&nbsp;<b>bitwise</b><b> </b>"or"
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res = bit.bxor( v1, v2, ... ): <b>bitwise</b><b> </b>"exclusive or"
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res = bit.lshift( value, pos ): shift "value" left "pos" positions.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res = bit.rshift( value, pos ): shift "value" right "pos" positions. The sign is
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp; not propagated.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res = bit.arshift( value, pos ): shift "value" right "pos" positions. The sign
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp; is propagated ("arithmetic shift").
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res = bit.bit( bitno ): a shortcut for bit.lshift( 1, bitno )
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res1, Res2, ... = bit.set( bitno, v1, v2, ... ): set the bit at position "bitno"
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp; in v1, v2, ... to 1.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res1, Res2, ... = bit.clear( bitno, v1, v2, ... ): set the bit at position
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp; "bitno"in v1, v2, ... to 0.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res = bit.isset( value, bitno ): returns true if bit at position "bitno" in
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp; "value" is 1, false otherwise.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
Res = bit.isclear( value, bitno ): returns true if bit at position "bitno" in
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp; "value" is 0, false otherwise.
</p>
<br style="font-family: Verdana;"></body></html>