Previous Section Next Section Table of Contents Glossary Index

Chapter 4. Using Clozure CL

4.11. Floating Point Numbers

In Clozure CL, the Common Lisp types short-float and single-float are implemented as IEEE single precision values; double-float and long-float are IEEE double precision values. On 64-bit platforms, single-floats are immediate values (like fixnums and characters).

Floating-point exceptions are generally enabled and detected. By default, threads start up with overflow, division-by-zero, and invalid enabled, and the rounding mode is set to nearest. The functions SET-FPU-MODE and GET-FPU-MODE provide user control over floating-point behavior.

[Function]

get-fpu-mode &optional mode
Return the state of exception-enable and rounding-mode control flags for the current thread.

Arguments and Values:

mode--- One of the keywords :rounding-mode, :overflow, :underflow, :division-by-zero, :invalid, :inexact.

Description:

If mode is supplied, returns the value of the corresponding control flag for the current thread.

Otherwise, returns a list of keyword/value pairs which describe the floating-point exception-enable and rounding-mode control flags for the current thread.

rounding-mode--- One of :nearest, :zero, :positive, :negative

overflow, underflow, division-by-zero, invalid, inexact --- If true, the floating-point exception is signaled. If NIL, it is masked.

[Function]

set-fpu-mode &key rounding-mode overflow underflow division-by-zero invalid inexact
Set the state of exception-enable and rounding-mode control flags for the current thread.

Arguments and Values:

rounding-mode--- If supplied, must be one of :nearest, :zero, :positive, or :negative.

overflow, underflow, division-by-zero, invalid, inexact---NIL to mask the exception, T to signal it.

Description:

Sets the current thread's exception-enable and rounding-mode control flags to the indicated values for arguments that are supplied, and preserves the values assoicated with those that aren't supplied.


Previous Section Next Section Table of Contents Glossary Index