next up previous contents
Next: NAN Not-a-Number Constant Up: Base Constants Previous: Base Constants   Contents

Subsections

INF Infinity Constant

Usage

Returns a value that represents positive infinity for both 32 and 64-bit floating point values.

   y = inf

The returned type is a 32-bit float, but promotion to 64 bits preserves the infinity.

Function Internals

The infinity constant has several interesting properties. In particular:

\begin{displaymath}
\begin{array}{ll}
\infty \times 0 & = \mathrm{NaN} \\
\in...
...\infty & = \mathrm{NaN} \\
\infty / 0 & = \infty
\end{array}\end{displaymath}

Note that infinities are not preserved under type conversion to integer types (see the examples below).

Example

The following examples demonstrate the various properties of the infinity constant.

--> inf*0
ans = 
  <float>  - size: [1 1]
    nan             
--> inf*2
ans = 
  <float>  - size: [1 1]
    inf             
--> inf*-2
ans = 
  <float>  - size: [1 1]
   -inf             
--> inf/inf
ans = 
  <float>  - size: [1 1]
    nan             
--> inf/0
ans = 
  <float>  - size: [1 1]
    inf             
--> inf/nan
ans = 
  <float>  - size: [1 1]
    nan

Note that infinities are preserved under type conversion to floating point types (i.e., float, double, complex and dcomplex types), but not integer types.

--> uint32(inf)
ans = 
  <uint32>  - size: [1 1]
            0  
--> complex(inf)
ans = 
  <complex>  - size: [1 1]
    inf               0.00000000    i



Samit K. Basu 2005-03-16