Shl.htm 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>Shl repetitions</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. repetitions = number of shifts to make left
  13. </td>
  14. </tr>
  15. </table>
  16. <h1>Description</h1>
  17. <table>
  18. <tr>
  19. <td>
  20. This performs a left binary shift on the value the specified number of times. This basically is a faster method of multiplying the value exponentially. By shifting left once, you are multiplying the value by 2. By shifting left twice, you multiple by 4, etc. <br />
  21. <br />
  22. The usefulness of this command is basically faster math execution.
  23. </td>
  24. </tr>
  25. </table>
  26. <h1><a href=../2d_examples/Shl.bb>Example</a></h1>
  27. <table>
  28. <tr>
  29. <td>
  30. ; shl, shr, sar examples <br />
  31. <br />
  32. value = 100 <br />
  33. <br />
  34. ; multiple x 2 <br />
  35. Print "Shift 1 bit left; Value = " + value Shl 1 <br />
  36. ; multiple x 4 <br />
  37. Print "Shift 2 bits left; Value = " + value Shl 2 <br />
  38. ; multiple x 16 <br />
  39. Print "Shift 4 bits left; Value = " + value Shl 4 <br />
  40. ; divide by 2 <br />
  41. Print "Shift 1 bit right; Value = " + value Shr 1 <br />
  42. ; divide by 4 <br />
  43. Print "Shift 2 bits right; Value = " + value Shr 2 <br />
  44. ; divide by 16 <br />
  45. Print "Shift 4 bits right; Value = " + value Shr 4 <br />
  46. <br />
  47. Print "Shift by SAR 4 times = " + value Sar 4 <br />
  48. <br />
  49. WaitKey() <br />
  50. </td>
  51. </tr>
  52. </table>
  53. <br>
  54. <a target=_top href=../index.htm>Index</a><br>
  55. <br>
  56. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=Shl&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  57. </html>