close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

Everything in Oct resides in the NET.COMMON-LISP.OCT package, with a nickname of OCT. The basic arithmetic operations of CL are shadowed in this package so you can use natural Lisp expressions to operate on quad-doubles. Special functions are included.

There are two types added:

A quad-double type. This has about 65 digits of precision, or about 212 bits.
A complex type consisting of two QD-REAL values.

The reader is also modified to make it easier to enter quad-double values. To enable the reader, bind *readtable* to oct::*oct-readtable*. #q is used to enter both QD-REAL and QD-COMPLEX types. For example #q1.25q5 is the QD-REAL with the value 125000. The exponent marker is q. To enter a QD-COMPLEX value, use #q(r i) where r and i are the real and imaginary parts. The parts will be coerced to QD-REAL type if necessary.

Here are a few examples of using OCT:

  CL-USER (in-package "OCT")
  OCT> (/ (sqrt #q3) 2)
  OCT> (sin (/ +pi+ 3))
  OCT> (sqrt #q-1)
  #q(#q0.0q0 #q1.0q0)
  OCT> (coerce 7 'qd-complex)
  #q(#q7.0q0 #q0.0q0)
  OCT> (integer-decode-float +pi+)
  OCT> +pi+
  OCT> (* 4 (atan #q1))

Note that +pi+ is the QD-REAL value for pi.

Last modified 9 years ago Last modified on 11/24/13 18:49:03