Difference between revisions of "Ceiling"
From Xojo Documentation
(Created page with "n/a") |
|||
Line 1: | Line 1: | ||
− | + | {{MethodBox | |
+ | | name=Ceiling | ||
+ | | platform=all | ||
+ | | scope=global | ||
+ | | owner=global | ||
+ | | returntype=[[Double]] | ||
+ | | parameters=value as [[Double]] | ||
+ | }} | ||
+ | |||
+ | == Usage == | ||
+ | ''result'' = '''Ceiling'''(''value'') | ||
+ | {| class="genericTable" | ||
+ | ! width=15% | Part | ||
+ | ! width=55% | Description | ||
+ | |- | ||
+ | |result | ||
+ | |The ceiling of ''value''. | ||
+ | |- | ||
+ | |value | ||
+ | |The value you want the ceiling of. | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | ==Notes== | ||
+ | The result of this function is a [[Double]], but it will always contain a whole number. | ||
+ | |||
+ | == Sample Code == | ||
+ | This code uses the '''Ceiling''' function to return ceiling of a number. | ||
+ | <rbcode> | ||
+ | Var d As Double | ||
+ | d = Ceiling(1.234) // returns 2 | ||
+ | </rbcode> | ||
+ | |||
+ | Because '''Ceiling''' will always return a whole number, to round a decimal value to a certain number of places, you must first multiple the number by 10^(the number of decimal places to which you wish to round) then take the value returned by '''Ceiling''' of that number and divide it by 10^(the number of decimal places to which you wish to round). In this code, the value 1.2345 is being rounded to two decimal places: | ||
+ | <rbcode> | ||
+ | Var d As Double | ||
+ | d = Ceiling(1.234 * 100) / 100 | ||
+ | </rbcode> | ||
+ | |||
+ | ==See Also== | ||
+ | [[Xojo.Math.Ceil]], [[Floor]], [[Round]] functions. | ||
+ | |||
+ | [[Category:Language_Math]] | ||
+ | [[Category:API 2.0]] |
Revision as of 20:23, 2 April 2020
Global Method
Usage
result = Ceiling(value)
Part | Description |
---|---|
result | The ceiling of value. |
value | The value you want the ceiling of. |
Notes
The result of this function is a Double, but it will always contain a whole number.
Sample Code
This code uses the Ceiling function to return ceiling of a number.
Because Ceiling will always return a whole number, to round a decimal value to a certain number of places, you must first multiple the number by 10^(the number of decimal places to which you wish to round) then take the value returned by Ceiling of that number and divide it by 10^(the number of decimal places to which you wish to round). In this code, the value 1.2345 is being rounded to two decimal places:
See Also
Xojo.Math.Ceil, Floor, Round functions.