Ceiling: Difference between revisions

Jump to navigation Jump to search
338 bytes added ,  21:57, 28 November 2022
m
m (Text replacement - " ⊢( *[^∘])" to " ⎕←$1")
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Built-in|Ceiling|⌈}} is a [[monadic]] [[scalar function]] that gives the [[wikipedia:floor and ceiling functions|ceiling]] of a real number, that is, the least integer [[Comparison tolerance|tolerantly]] [[greater than or equal to]] the given value. This operation is also known as '''round up'''. Ceiling shares the [[glyph]] <source lang=apl inline>⌈</source> with the dyadic arithmetic function [[Maximum]]. [[Comparison_with_traditional_mathematics#Prefix|Traditional mathematics]] derives [[Ken_Iverson#Floor_and_Ceiling|its notation]] and name for ceiling from APL.
{{Built-in|Ceiling|⌈}} is a [[monadic]] [[scalar function]] that gives the [[wikipedia:floor and ceiling functions|ceiling]] of a real number, that is, the least integer tolerantly<ref>[[Robert Bernecky|Bernecky, Robert]]. [https://www.jsoftware.com/papers/satn23.htm "Comparison Tolerance"]. Sharp APL Technical Notes. 1977-06-10;.</ref> [[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#Prefix|Traditional mathematics]] derives [[Ken_Iverson#Floor_and_Ceiling|its 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.


<source lang=apl>
<syntaxhighlight lang=apl>
       ⌈2 2.8 ¯2 ¯2.8
       ⌈2 2.8 ¯2 ¯2.8
2 3 ¯2 ¯2
2 3 ¯2 ¯2
</source>
</syntaxhighlight>


== Properties ==
== Properties ==
Line 16: Line 16:
Ceiling is affected by [[comparison tolerance]]. If the given number is [[tolerant comparison|tolerantly equal]] to its [[floor]], it is rounded to that number instead.
Ceiling is affected by [[comparison tolerance]]. If the given number is [[tolerant comparison|tolerantly equal]] to its [[floor]], it is rounded to that number instead.


<source lang=apl>
<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
</source>
</syntaxhighlight>


Ceiling is the dual to [[Floor]] by [[negate|negation]].
Ceiling is the dual to [[Floor]] by [[negate|negation]].


<source lang=apl>
<syntaxhighlight lang=apl>
       v←2 2.8 ¯2 ¯2.8
       v←2 2.8 ¯2 ¯2.8
       (⌈v)≡-⌊-v
       (⌈v)≡-⌊-v
1
1
</source>
</syntaxhighlight>


The extension for [[complex number|complex numbers]] is derived from [[complex Floor]] via this property.
The extension for [[complex number|complex numbers]] is derived from [[complex Floor]] via this property.


<source lang=apl>
<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
</source>{{Works in|[[Dyalog APL]]}}
</syntaxhighlight>{{Works in|[[Dyalog APL]]}}


== External links ==
== External links ==
Line 46: Line 46:
=== Documentation ===
=== Documentation ===


* [http://help.dyalog.com/latest/#Language/Primitive%20Functions/Ceiling.htm Dyalog]
* [https://help.dyalog.com/latest/#Language/Primitive%20Functions/Ceiling.htm Dyalog]
* [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#additional-arithmetic BQN]
== References ==
<references />
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar monadic functions]]
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar monadic functions]]

Navigation menu