Vocabulary/under

From J Wiki
Jump to navigation Jump to search

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

_ Negative Sign Other

As the first character of a numeric constant, (_) acts as a negative sign to produce a negative constant.

The two-character constant (__) combines these usages and represents Negative infinity.

The negative sign (_) is part of the number (constant) that follows it. Any noun that begins with a negative sign must be a valid number. This is different from applying Negate (-), which is a verb primitive that forms a phrase to be evaluated.

   5 _3 22
5 _3 22
   5 -3 22   NB. equivalent to: 5 - (3 22)
2 _17

Common uses

1. Embed negative numbers in a numeric vector or matrix.


Related Primitives

Negate (- y)


_ Infinity Noun

Standing by itself, (_) represents the value Infinity (an IEEE floating-point value).


Common uses

1. Use as a docile placeholder in a numeric vector or matrix.

   ]z=: 2 3$ 0 1 _ 3 4 5
0 1 _
3 4 5
   1+z
1 2 _
4 5 6
   _ = z
0 0 1
0 0 0
   _ = 1+z
0 0 1
0 0 0

Note that (_) is a floating-point value and its use will force the entire array to be floating-point.

2. Specify (_) as the placeholder to be used for a badly-formed numeral when converting a string using Numbers (".).

   _ ". '33 -44 55.5 66.6.6 _77'
33 _44 55.5 _ _77

Note: the use of (_) here is better-behaved in practice than Indeterminate (_.)


Details

1. Some normally-indeterminate forms involving infinity are defined in J:

  • 0 * _ = 0
  • 0 * __ = 0
  • _ ^ 0 = 1
  • 1 ^ _ = 1