Ceiling: Difference between revisions
Jump to navigation
Jump to search
m (Text replacement  "http://help.dyalog.com" to "https://help.dyalog.com") 
m (Text replacement  "<source" to "<syntaxhighlight") 

(2 intermediate revisions by 2 users not shown)  
Line 1:  Line 1:  
{{BuiltinCeiling⌈}} is a [[monadic]] [[scalar function]] that gives the [[wikipedia:floor and ceiling functionsceiling]] of a real number, that is, the least integer [[Comparison tolerancetolerantly]] [[greater than or equal to]] the given value. This operation is also known as '''round up'''. Ceiling shares the [[glyph]] <  {{BuiltinCeiling⌈}} is a [[monadic]] [[scalar function]] that gives the [[wikipedia:floor and ceiling functionsceiling]] of a real number, that is, the least integer [[Comparison tolerancetolerantly]] [[greater than or equal to]] the given value. This operation is also known as '''round up'''. Ceiling shares the [[glyph]] <syntaxhighlight lang=apl inline>⌈</syntaxhighlight> with the dyadic arithmetic function [[Maximum]]. [[Comparison_with_traditional_mathematics#PrefixTraditional mathematics]] derives [[Ken_Iverson#Floor_and_Ceilingits notation]] and name for ceiling from APL.  
== Examples ==  == Examples ==  
Line 5:  Line 5:  
Ceiling rounds up the given numbers to the nearest integers.  Ceiling rounds up the given numbers to the nearest integers.  
<  <syntaxhighlight lang=apl>  
⌈2 2.8 ¯2 ¯2.8  ⌈2 2.8 ¯2 ¯2.8  
2 3 ¯2 ¯2  2 3 ¯2 ¯2  
</  </syntaxhighlight>  
== Properties ==  == Properties ==  
Line 16:  Line 16:  
Ceiling is affected by [[comparison tolerance]]. If the given number is [[tolerant comparisontolerantly equal]] to its [[floor]], it is rounded to that number instead.  Ceiling is affected by [[comparison tolerance]]. If the given number is [[tolerant comparisontolerantly equal]] to its [[floor]], it is rounded to that number instead.  
<  <syntaxhighlight lang=apl>  
⎕PP←16  ⎕PP←16  
⎕←v←1+0.6×⎕CT×0 1 2  ⎕←v←1+0.6×⎕CT×0 1 2  
Line 22:  Line 22:  
⌈v  ⌈v  
1 1 2  1 1 2  
</  </syntaxhighlight>  
Ceiling is the dual to [[Floor]] by [[negatenegation]].  Ceiling is the dual to [[Floor]] by [[negatenegation]].  
<  <syntaxhighlight lang=apl>  
v←2 2.8 ¯2 ¯2.8  v←2 2.8 ¯2 ¯2.8  
(⌈v)≡⌊v  (⌈v)≡⌊v  
1  1  
</  </syntaxhighlight>  
The extension for [[complex numbercomplex numbers]] is derived from [[complex Floor]] via this property.  The extension for [[complex numbercomplex numbers]] is derived from [[complex Floor]] via this property.  
<  <syntaxhighlight lang=apl>  
v←1.8J2.5 2.5J2.2 1.7J2.2  v←1.8J2.5 2.5J2.2 1.7J2.2  
⌈v  ⌈v  
Line 40:  Line 40:  
(⌈v)≡⌊v  (⌈v)≡⌊v  
1  1  
</  </syntaxhighlight>{{Works in[[Dyalog APL]]}}  
== External links ==  == External links ==  
Line 49:  Line 49:  
* [http://microapl.com/apl_help/ch_020_020_090.htm APLX]  * [http://microapl.com/apl_help/ch_020_020_090.htm APLX]  
* [https://www.jsoftware.com/help/dictionary/d021.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/gtdot NuVoc]  * [https://www.jsoftware.com/help/dictionary/d021.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/gtdot NuVoc]  
* [https://mlochbaum.github.io/BQN/doc/arithmetic.html#additionalarithmetic BQN]  
{{APL builtins}}[[Category:Primitive functions]][[Category:Scalar monadic functions]]  {{APL builtins}}[[Category:Primitive functions]][[Category:Scalar monadic functions]] 
Latest revision as of 22:12, 10 September 2022
⌈

Ceiling (⌈
) is a monadic scalar function that gives the ceiling of a real number, that is, the least integer tolerantly greater than or equal to the given value. This operation is also known as round up. Ceiling shares the glyph ⌈
with the dyadic arithmetic function Maximum. Traditional mathematics derives its notation and name for ceiling from APL.
Examples
Ceiling rounds up the given numbers to the nearest integers.
⌈2 2.8 ¯2 ¯2.8
2 3 ¯2 ¯2
Properties
The ceiling of any real number is an integer.
Ceiling is affected by comparison tolerance. If the given number is tolerantly equal to its floor, it is rounded to that number instead.
⎕PP←16
⎕←v←1+0.6×⎕CT×0 1 2
1 1.000000000000006 1.000000000000012
⌈v
1 1 2
Ceiling is the dual to Floor by negation.
v←2 2.8 ¯2 ¯2.8
(⌈v)≡⌊v
1
The extension for complex numbers is derived from complex Floor via this property.
v←1.8J2.5 2.5J2.2 1.7J2.2
⌈v
2J3 3J2 2J2
(⌈v)≡⌊v
1
Works in: Dyalog APL