Difference between revisions of "Datatype functions"
Line 5: | Line 5: | ||
A value can be a number, text, <code>Null</code>, or a reference. Integers, reals, Boolean, and date values, are all represented as numbers. You can use these functions from the '''Special '''library of '''Definition '''menu to determine the type. | A value can be a number, text, <code>Null</code>, or a reference. Integers, reals, Boolean, and date values, are all represented as numbers. You can use these functions from the '''Special '''library of '''Definition '''menu to determine the type. | ||
− | '''IsNumber(x)''': Returns <code>True</code> if <code>x</code> is a number, including a boolean, date, <code>INF</code>, <code>NAN</code>, or complex. | + | ''[['IsNumber]](x)''': Returns <code>True</code> if <code>x</code> is a number, including a boolean, date, <code>INF</code>, <code>NAN</code>, or complex. |
:<code>IsNumber(0) → True </code> | :<code>IsNumber(0) → True </code> | ||
:<code>IsNumber(False) → True </code> | :<code>IsNumber(False) → True </code> | ||
Line 14: | Line 14: | ||
:<code>IsNumber(NAN) → True</code> | :<code>IsNumber(NAN) → True</code> | ||
− | '''IsText(x)''': Returns <code>True</code> if <code>x</code> is a text value. | + | '''[[IsText]](x)''': Returns <code>True</code> if <code>x</code> is a text value. |
:<code>IsText('hello') → True </code> | :<code>IsText('hello') → True </code> | ||
:<code>IsText(7) → False</code> | :<code>IsText(7) → False</code> | ||
:<code>IsText('7') → True</code> | :<code>IsText('7') → True</code> | ||
− | '''IsNaN(x)''': Returns <code>True</code> if <code>x</code> is “not a number,” i.e., <code>NAN</code>. <code>INF</code> or regular numbers do not qualify, nor does a text or <code>Null</code>. | + | '''[[IsNaN]](x)''': Returns <code>True</code> if <code>x</code> is “not a number,” i.e., <code>NAN</code>. <code>INF</code> or regular numbers do not qualify, nor does a text or <code>Null</code>. |
:<code>0/0 → NAN</code> | :<code>0/0 → NAN</code> | ||
:<code>IsNaN(0/0) → True </code> | :<code>IsNaN(0/0) → True </code> | ||
Line 26: | Line 26: | ||
:<code>IsNaN('Hello') → False</code> | :<code>IsNaN('Hello') → False</code> | ||
− | '''IsNull(x)''': To test if <code>x</code> is exactly <code>Null</code>. Returns false if <code>x</code> is an array. | + | '''[[IsNull]](x)''': To test if <code>x</code> is exactly <code>Null</code>. Returns false if <code>x</code> is an array. |
'''x <nowiki>=</nowiki> NULL''': To test if an atomic <code>x</code> is <code>Null</code>. When <code>x</code> is an array, returns <code>True</code> or <code>False</code> for each element of the array. | '''x <nowiki>=</nowiki> NULL''': To test if an atomic <code>x</code> is <code>Null</code>. When <code>x</code> is an array, returns <code>True</code> or <code>False</code> for each element of the array. | ||
− | '''IsUndef(x)''': Returns <code>True</code> if atomic <code>x</code> is <code>Null</code>or the internal value '''Undefined '''(usually indicating uncomputed). When <code>x</code> is an array, returns <code>True</code> or <code>False</code> for each element of the array. | + | '''[[IsUndef]](x)''': Returns <code>True</code> if atomic <code>x</code> is <code>Null</code>or the internal value '''Undefined '''(usually indicating uncomputed). When <code>x</code> is an array, returns <code>True</code> or <code>False</code> for each element of the array. |
− | '''IsRealNumber(x)''': Returns <code>True</code> when <code>x</code> is a real number, including a boolean, date or <code>INF</code>. Returns <code>False</code> when <code>x</code> is a complex number or <code>NAN</code>. | + | '''[[IsRealNumber]](x)''': Returns <code>True</code> when <code>x</code> is a real number, including a boolean, date or <code>INF</code>. Returns <code>False</code> when <code>x</code> is a complex number or <code>NAN</code>. |
− | '''IsReference(x)''': Returns <code>True</code> if <code>x</code> is a reference to a value. | + | '''[[IsReference]](x)''': Returns <code>True</code> if <code>x</code> is a reference to a value. |
− | '''IsHandle(x)''': Returns <code>True</code> if <code>x</code> is a handle to an Analytica object. | + | '''[[IsHandle]](x)''': Returns <code>True</code> if <code>x</code> is a handle to an Analytica object. |
− | '''TypeOf(x)''': Returns the type of expression <code>x</code> as a text value, usually one of <code>Number, Text, Reference, or Null</code>. <code>INF</code> and <code>NAN</code> are both of type <code>"Number"</code>: | + | '''[[TypeOf]](x)''': Returns the type of expression <code>x</code> as a text value, usually one of <code>Number, Text, Reference, or Null</code>. <code>INF</code> and <code>NAN</code> are both of type <code>"Number"</code>: |
:<code>TypeOf(2008) → "Number" </code> | :<code>TypeOf(2008) → "Number" </code> | ||
:<code>TypeOf('2008') → "Text" </code> | :<code>TypeOf('2008') → "Text" </code> |
Revision as of 08:32, 16 November 2015
A value can be a number, text, Null
, or a reference. Integers, reals, Boolean, and date values, are all represented as numbers. You can use these functions from the Special library of Definition menu to determine the type.
'IsNumber(x)': Returns True
if x
is a number, including a boolean, date, INF
, NAN
, or complex.
IsNumber(0) → True
IsNumber(False) → True
IsNumber(INF) → True
IsNumber('hi') → False
IsNumber(5) → True
IsNumber('5') → False
IsNumber(NAN) → True
IsText(x): Returns True
if x
is a text value.
IsText('hello') → True
IsText(7) → False
IsText('7') → True
IsNaN(x): Returns True
if x
is “not a number,” i.e., NAN
. INF
or regular numbers do not qualify, nor does a text or Null
.
0/0 → NAN
IsNaN(0/0) → True
IsNaN(5) → False
IsNaN(INF) → False
IsNaN('Hello') → False
IsNull(x): To test if x
is exactly Null
. Returns false if x
is an array.
x = NULL: To test if an atomic x
is Null
. When x
is an array, returns True
or False
for each element of the array.
IsUndef(x): Returns True
if atomic x
is Null
or the internal value Undefined (usually indicating uncomputed). When x
is an array, returns True
or False
for each element of the array.
IsRealNumber(x): Returns True
when x
is a real number, including a boolean, date or INF
. Returns False
when x
is a complex number or NAN
.
IsReference(x): Returns True
if x
is a reference to a value.
IsHandle(x): Returns True
if x
is a handle to an Analytica object.
TypeOf(x): Returns the type of expression x
as a text value, usually one of Number, Text, Reference, or Null
. INF
and NAN
are both of type "Number"
:
TypeOf(2008) → "Number"
TypeOf('2008') → "Text"
TypeOf(INF) → "Number"
TypeOf(0/0) → "Number"
Enable comment auto-refresher