This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,13 @@
def negInf = -1.0d / 0.0d; //also Double.NEGATIVE_INFINITY
def inf = 1.0d / 0.0d; //also Double.POSITIVE_INFINITY
def nan = 0.0d / 0.0d; //also Double.NaN
def negZero = -2.0d / inf;
println(" Negative inf: " + negInf);
println(" Positive inf: " + inf);
println(" NaN: " + nan);
println(" Negative 0: " + negZero);
println(" inf + -inf: " + (inf + negInf));
println(" 0 * NaN: " + (0 * nan));
println(" NaN == NaN: " + (nan == nan));
println("NaN equals NaN: " + (nan.equals(nan)));

View file

@ -0,0 +1,4 @@
Inf=: _
NegInf=: __
NB. Negative zero cannot be represented in J.
NaN=. _.

View file

@ -0,0 +1,15 @@
(1 % 0) , (_1 % 0)
_ __
(1e234 * 1e234) , (_1e234 * 1e234)
_ __
_ + __ NB. generates NaN error, rather than NaN
|NaN error
| _ +__
_ - _ NB. generates NaN error, rather than NaN
|NaN error
| _ -_
%_
0
%__ NB. Under the covers, the reciprocal of NegInf produces NegZero, but this fact isn't exposed to the user, who just sees zero
0

View file

@ -0,0 +1,8 @@
_ + _
_
__ + __
__
Inf + 0
_
NegInf * 0
0

View file

@ -0,0 +1,15 @@
EXTREMES
NEW INF,NINF,ZERO,NOTNUM,NEGZERO
SET INF=$DOUBLE(3.0E310),NINF=$DOUBLE(-3.0E310),ZERO=$DOUBLE(0),NOTNUM=$DOUBLE(INF-INF),NEGZERO=$DOUBLE(ZERO*-1)
WRITE "Infinity: ",INF,!
WRITE "Infinity ",$SELECT($ISVALIDNUM(INF):"is a number",1:"is not a number"),!
WRITE "Negative Infinity: ",NINF,!
WRITE "Negative Infinity ",$SELECT($ISVALIDNUM(NINF):"is a number",1:"is not a number"),!
WRITE "Zero: ",ZERO,!
WRITE "Zero ",$SELECT($ISVALIDNUM(ZERO):"is a number",1:"is not a number"),!
WRITE "Negative Zero: ",NEGZERO,!
WRITE "Negative Zero ",$SELECT($ISVALIDNUM(NEGZERO):"is a number",1:"is not a number"),!
WRITE "Not a Number: ",NOTNUM,!
WRITE "Not a Number ",$SELECT($ISVALIDNUM(NOTNUM):"is a number",1:"is not a number"),!
KILL INF,NINF,ZERO,NONNUM,NEGZERO
QUIT

View file

@ -0,0 +1,9 @@
Column@{ReleaseHold[
Function[expression,
Row@{HoldForm@InputForm@expression, " = ", Quiet@expression},
HoldAll] /@
Hold[1./0., 0./0., Limit[-Log[x], x -> 0], Limit[Log[x], x -> 0],
Infinity + 1, Infinity + Infinity, 2 Infinity,
Infinity - Infinity, 0 Infinity, ComplexInfinity + 1,
ComplexInfinity + ComplexInfinity, 2 ComplexInfinity,
0 ComplexInfinity, Indeterminate + 1, 0 Indeterminate]]}