Ceiling: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (Text replacement - "</source>" to "</syntaxhighlight>")
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 [[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>⌈</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 8: Line 8:
       ⌈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 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]].
Line 30: Line 30:
       (⌈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.
Line 40: Line 40:
       (⌈v)≡-⌊-v
       (⌈v)≡-⌊-v
1
1
</source>{{Works in|[[Dyalog APL]]}}
</syntaxhighlight>{{Works in|[[Dyalog APL]]}}


== External links ==
== External links ==

Revision as of 21:51, 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 <source lang=apl inline>⌈</syntaxhighlight> 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.

<source lang=apl>

     ⌈2 2.8 ¯2 ¯2.8

2 3 ¯2 ¯2 </syntaxhighlight>

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.

<source lang=apl>

     ⎕PP←16
     ⎕←v←1+0.6×⎕CT×0 1 2

1 1.000000000000006 1.000000000000012

     ⌈v

1 1 2 </syntaxhighlight>

Ceiling is the dual to Floor by negation.

<source lang=apl>

     v←2 2.8 ¯2 ¯2.8
     (⌈v)≡-⌊-v

1 </syntaxhighlight>

The extension for complex numbers is derived from complex Floor via this property.

<source lang=apl>

     v←1.8J2.5 2.5J2.2 1.7J2.2
     ⌈v

2J3 3J2 2J2

     (⌈v)≡-⌊-v

1

</syntaxhighlight>

Works in: Dyalog APL

External links

Documentation

APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare RootRound
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axisIdentity (Null, Ident)
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)Identity (Lev, Dex)
Quad names Index originComparison toleranceMigration levelAtomic vector