Applied docspak188.
This commit is contained in:
@@ -1,12 +1,90 @@
|
||||
<html><head><title>Command: Floor# </title><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'><link rel='stylesheet' href='../css/commands.css' type='text/css'></head><body><span class='Command'> Floor# (float) </span></p><span class='header'>Definition:</span> <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>Rounds a decimal floating variable down to the nearest whole number.</td></tr></table><span class='header'><br>Parameter Description:</span> <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>float=floating point number</td></tr></table><p class='header'>Command Description: <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>Many times, you will need to round up or down a floating point decimal variable. This command rounds it down to the nearest whole number. Use <a href='Ceil#.htm'>Ceil#</a> to round the number up.</td></tr></table><p class='header'>Example: <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>; Floor#/Ceil# Example<br>
|
||||
<html>
|
||||
<head>
|
||||
<title>Blitz3D Docs</title>
|
||||
<link rel=stylesheet href=../css/commands.css type=text/css>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Floor# ( y# )</h1>
|
||||
<h1>Parameters</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
y = any number
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h1>Description</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
Rounds downward, i.e. in the direction of -Infinity.
|
||||
|
||||
<br />
|
||||
|
||||
<br />
|
||||
It is a common mistake to think this simply sets everything after the decimal point to zero.
|
||||
|
||||
<br />
|
||||
But this is true only for positive numbers:
|
||||
|
||||
<br />
|
||||
|
||||
<br />
|
||||
Floor( 1.75 ) ....... 1.0
|
||||
|
||||
<br />
|
||||
Floor( -1.75 ) .... -2.0
|
||||
|
||||
<br />
|
||||
|
||||
<br />
|
||||
See also Ceil and Int for other types of rounding.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h1><a href=../2d_examples/Floor.bb>Example</a></h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
; Ceil / Floor / Int example, three kinds of rounding.
|
||||
<br />
|
||||
|
||||
<br />
|
||||
; Move mouse. Escape quits.
|
||||
<br />
|
||||
|
||||
<br />
|
||||
Graphics 640, 480
|
||||
<br />
|
||||
|
||||
<br />
|
||||
Const KEY_ESC = 1
|
||||
<br />
|
||||
|
||||
<br />
|
||||
SetBuffer BackBuffer()
|
||||
<br />
|
||||
Origin 320, 240
|
||||
<br />
|
||||
|
||||
<br />
|
||||
MoveMouse 320, 240 : HidePointer
|
||||
<br />
|
||||
|
||||
<br />
|
||||
While Not KeyDown( KEY_ESC )
|
||||
<br />
|
||||
|
||||
<br />
|
||||
Cls
|
||||
<br />
|
||||
|
||||
<br />
|
||||
my = MouseY() - 240
|
||||
<br />
|
||||
Color 100, 100, 0
|
||||
<br />
|
||||
; Set a floating point variable<br>
|
||||
myVal#=0.5<br>
|
||||
Line -320, my, 319, my
|
||||
<br />
|
||||
; Round it up<br>
|
||||
Print Floor#(myval)<br>
|
||||
<br>
|
||||
;Round it down<br>
|
||||
Print Ceil#(myval)<br>
|
||||
</td></tr></table><p><b><a target="_top" href="../index.htm">Index</a></b></p></body>
|
||||
|
||||
<br />
|
||||
|
||||
Reference in New Issue
Block a user