Vocabulary/percent

From J Wiki
Jump to navigation Jump to search

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

% y Reciprocal

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


Equivalent to 1 % y, the reciprocal of the number y

   % 2
0.5
   % i.6
_ 1 0.5 0.333333 0.25 0.2

Details

1. The reciprocals of positive and negative infinity are positive and negative zero. Positive and negative zero are equal in all comparisons and behave identically except when you divide by them:

   poszero =: % _
   negzero =: % __
   poszero =!.0 negzero
1
   % poszero
_
   % negzero
__

The details of positive and negative zero are not repeatable across all J platforms.

More Information

Reciprocal video


x % y Divide

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


x divided by y

   1 % 2
0.5
   100 % i.6
_ 100 50 33.3333 25 20

Details

1. 0 % 0 produces 0. See design rationale in the paper by E. E. McDonnell.

2. Dividing nonzero by positive or negative infinity produces positive or negative zero, and vice versa.

The details of positive and negative zero are not repeatable across all J platforms.

Positive and negative zero are equal in all comparisons and behave identically except when you divide by them.

   poszero =: % _
   negzero =: % __
   1 % (1 % _)
_
   1 % (1 % __)
__

3. Dividing zero by a nonzero produces positive or negative zero.

   % 0 % _1
__
   % negzero % _1
_

4. Dividing nonzero by positive or negative zero gives positive or negative infinity.

5. Dividing an extended integer by an integer (extended or not) produces an extended integer if the quotient is an integer, or a rational otherwise.



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

Mean on infixes integer and floating-point x (+/%#)\ y x positive

*. = ~: in place of +

much faster than alternatives
Find mean of each partition x (+/ % #)/. y avoids building argument cells
Integer divide integer x <.@% y

x >.@% y

@: in place of @ uses integer division
Mean with rank (+/ % #) y Supported as a primitive by (+/ % #)"n