Files
BlitzNext/_release/help/commands/2d_commands/Shr.htm
T
2014-12-08 12:43:20 +13:00

59 lines
1.6 KiB
HTML

<html>
<head>
<title>Blitz3D Docs</title>
<link rel=stylesheet href=../css/commands.css type=text/css>
</head>
<body>
<h1>Shr repetitions</h1>
<h1>Parameters</h1>
<table>
<tr>
<td>
repetitions = number of shifts to make right
</td>
</tr>
</table>
<h1>Description</h1>
<table>
<tr>
<td>
This performs a left binary shift on the value the specified number of times. This basically is a faster method of dividing the value exponentially. By shifting right once, you are dividing the value by 2. By shifting right twice, you divide by 4, etc.
<br />
<br />
The usefulness of this command is basically faster math execution.
</td>
</tr>
</table>
<h1><a href=../2d_examples/Shr.bb>Example</a></h1>
<table>
<tr>
<td>
; shl, shr, sar examples
<br />
<br />
value = 100
<br />
<br />
; multiple x 2
<br />
Print "Shift 1 bit left; Value = " + value Shl 1
<br />
; multiple x 4
<br />
Print "Shift 2 bits left; Value = " + value Shl 2
<br />
; multiple x 16
<br />
Print "Shift 4 bits left; Value = " + value Shl 4
<br />
; divide by 2
<br />
Print "Shift 1 bit right; Value = " + value Shr 1
<br />
; divide by 4
<br />
Print "Shift 2 bits right; Value = " + value Shr 2
<br />
; divide by 16
<br />
Print "Shift 4 bits right; Value = " + value Shr 4
<br />
<br />
Print "Shift by SAR 4 times = " + value Sar 4
<br />
<br />
WaitKey()
<br />
</td>
</tr>
</table>
<br>
<a target=_top href=../index.htm>Index</a><br>
<br>
Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=Shr&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
</html>