Vocabulary/gtdot

From J Wiki
Jump to navigation Jump to search

>> <<   Down to: Dyad   Back to: Vocabulary Thru to: Dictionary

>. y Ceiling

Rank 0 -- operates on individual atoms of y, producing a result of the same shape -- WHY IS THIS IMPORTANT?


The ceiling of y i.e. the smallest integer greater than or equal to y

   >. 4.6
5

   >. 4.2 4.5 4.6
5 5 5

   >. 4.6 4 _4 _4.6
5 4 _4 _4

Warning.png The result of >. y may not have integer type.


If y is too large or too small to be represented as an integer, it will be left in floating point form. Furthermore, >. y is always complex for complex y.

Ceiling (>.) uses tolerant comparison. >. y is y rounded towards ∞, except that if y is tolerantly equal to an integer, >. y is that integer. For more information, read about tolerant floor and ceiling. To require exact comparison, use (>.!.0) in place of (>.) to temporarily set the comparison tolerance to zero.

   >. 100.000000000001
100
   >.!.0 (100.000000000001)
101

Common uses

1. Test whether numbers are integers or not.

can also use Floor (<.))

   3 3.14 5 = >. 3 3.14 5
1 0 1

2. Convert floating-point representations of integers (8 bytes per value) to integers (4 bytes per value) in order to save memory

Such values can arise as a result of arithmetic operations like Divide (%)

   ] N=: 27 % 9
3
   datatype N
floating
   ] n=: >. 27 % 9         NB. alternatively:  n=: 27 >.@:% 9
3
   datatype n
integer

Related Primitives

Floor (<. y)


Details

1. >. y is equal to - <. - y.

2. For complex y, consider the equivalent form: (- <. - y) and refer to complex floor.

3. >. y uses tolerant comparison, which means an integer is considered equal to y if its difference from y is less than the y*tolerance. If y is so big that y*tolerance is greater than 1, results can be surprising: the smallest integer tolerantly equal to y could be considerably smaller than y. The implementation defines >. y as the integer closest to y, if that integer is tolerantly equal to y; otherwise the next-larger integer.


Use These Combinations

Combinations using >. y that have exceptionally good performance include:

What it does Type;

Precisions;
Ranks

Syntax Variants;

Restrictions

Benefits;

Bug Warnings

Integer-result operations extended integer <.@f y

x <.@f y
(f is any verb)

<. in place of >. Avoids non-integer intermediate results
Integer divide integer x <.@% y

x >.@% y

@: in place of @ uses integer division


x >. y Larger of (Max)

Rank 0 0 -- operates on individual atoms of x and y, producing a result of the same shape -- WHY IS THIS IMPORTANT?


The larger atoms of x and y

   3 >. 4
4

   3 >. 4 _4
4 3

   2 3 >. 4 1
4 3

Common uses

1. Find the maximum value in a list

Use in conjunction with Insert (/)

   >./ 7 8 5 9 2
9

2. Find the running maximum in a list (scanned from left to right)

Use in conjunction with Insert (/) and Prefix (\)

   >./\ 7 8 5 9 2
7 8 8 9 9

Related Primitives

Lesser Of (Min) (x <. y)


More Information

0. Larger Of (Max) video

1. If an argument to x >. y is complex, its imaginary part must be tolerantly equal to 0, using the default tolerance of 2^_44 even if the comparison x >. y itself uses a different tolerance. The result will have floating-point precision.

2. If x >. y has arguments of different precisions, the arguments are converted to the higher-priority precision as described here. The conversion may turn an argument into a smaller or larger value, especially if a large 64-bit integer is converted to floating-point.

   <. 9223372036854765500 >. 0.5
9223372036854765568
   <. 9223372036854765580 >. 0.5
9223372036854765568

Use These Combinations

Combinations using x >. y that have exceptionally good performance include:

What it does Type;

Precisions;
Ranks

Syntax Variants;

Restrictions

Benefits;

Bug Warnings

Find index of first/last occurrence of largest/smallest value integer or floating-point list (i. <./) y

(i. >./) y

or i: it actually does (i. >.!.0/) etc.; is faster than 0 ({ /:~) y
Reductions on infixes Boolean, integer, floating-point x +/\ y <. >. in place of + much faster than alternatives
Boolean reductions on partitions Boolean x +//. y = <. >. +. * *. ~: in place of + avoids building argument cells
Reductions on partitions integer, floating-point x +//. y <. >. in place of + avoids building argument cells
Max/min along diagonals non-complex numeric >.//. y <. in place of >. avoids building argument cells