Ceil.htm 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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>Ceil# ( y# )</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. y = any number
  13. </td>
  14. </tr>
  15. </table>
  16. <h1>Description</h1>
  17. <table>
  18. <tr>
  19. <td>
  20. As with Floor there is often some confusion with negative numbers: <br />
  21. <br />
  22. Ceil( 1.75 ) ...... 2.0 <br />
  23. Ceil( -1.75 ) ... -1.0 <br />
  24. <br />
  25. See also Floor and Int for other types of rounding.
  26. </td>
  27. </tr>
  28. </table>
  29. <h1><a href=../2d_examples/Ceil.bb>Example</a></h1>
  30. <table>
  31. <tr>
  32. <td>
  33. ; Ceil / Floor / Int example, three kinds of rounding. <br />
  34. <br />
  35. ; Move mouse. Escape quits. <br />
  36. <br />
  37. Graphics 640, 480 <br />
  38. <br />
  39. Const KEY_ESC = 1 <br />
  40. <br />
  41. SetBuffer BackBuffer() <br />
  42. Origin 320, 240 <br />
  43. <br />
  44. MoveMouse 320, 240 : HidePointer <br />
  45. <br />
  46. While Not KeyDown( KEY_ESC ) <br />
  47. <br />
  48. Cls <br />
  49. <br />
  50. my = MouseY() - 240 <br />
  51. Color 100, 100, 0 <br />
  52. Line -320, my, 319, my <br />
  53. <br />
  54. DrawNumberLine <br />
  55. <br />
  56. y# = Float( -my ) / 32 <br />
  57. <br />
  58. Text 100, 50, " y = " + y <br />
  59. Text 100, 70, " Ceil( y ) = " + Ceil( y ) <br />
  60. Text 100, 90, " Floor( y ) = " + Floor( y ) <br />
  61. Text 100, 110, " Int( y ) = " + Int( y ) <br />
  62. <br />
  63. Flip <br />
  64. <br />
  65. Wend <br />
  66. End <br />
  67. <br />
  68. Function DrawNumberLine( ) ; vertical line with numeric labels <br />
  69. <br />
  70. Color 255, 255, 255 <br />
  71. Line 0, -240, 0, 239 <br />
  72. <br />
  73. For n = -7 To 7 <br />
  74. yn = -32 * n <br />
  75. Line -2, yn, 2, yn <br />
  76. Text -30, yn - 6, RSet( n, 2 ) <br />
  77. Next <br />
  78. <br />
  79. End Function
  80. </td>
  81. </tr>
  82. </table>
  83. <br>
  84. <a target=_top href=../index.htm>Index</a><br>
  85. <br>
  86. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=Ceil&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  87. </html>