This is the fixed Reference Manual, version 0.0.2, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 06:07:11 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
fixed
A fixed-point number type.
Nick Patrick <npatrick04@gmail.com>
MIT
0.0.2
src
(module).
Modules are listed depth-first from the system components tree.
fixed/src
fixed
(system).
package.lisp
(file).
reader.lisp
(file).
fixed.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
fixed/src/reader.lisp
src
(module).
install-q-reader
(function).
q-reader-error
(condition).
q-reader-invalid-value
(condition).
q-reader-non-symbol
(condition).
q-reader-unknown-fixed-type
(condition).
+whitespace+
(constant).
clear-whitespace
(function).
q-ratio
(function).
q-reader
(function).
q-reader-invalid-value-message
(reader method).
ratio-meets-spec?
(function).
read-decimal-q
(function).
read-decimal-q-decimal
(function).
read-integer
(function).
read-ordinary-q
(function).
read-ordinary-q-decimal
(function).
read-q-character-spec
(function).
read-q-decimal
(function).
read-sign
(function).
read-user-decimal
(function).
read-user-ordinary
(function).
spec-small
(function).
unknown-fixed-type-symbol
(reader method).
fixed/src/fixed.lisp
src
(module).
*rounding-method*
(special variable).
decimal-fixedp
(generic function).
defdecimal
(macro).
defdelta
(macro).
delta
(generic function).
f*
(generic function).
f+
(generic function).
f-
(generic function).
f/
(generic function).
f/=
(generic function).
f<
(generic function).
f<=
(generic function).
f=
(generic function).
f>
(generic function).
f>=
(generic function).
fixedp
(generic function).
fp
(class).
make-load-form
(method).
ordinary-fixedp
(generic function).
ordinary-fp
(class).
ranged-fixedp
(generic function).
size
(generic function).
small
(generic function).
%defdelta
(macro).
decimal-fp
(class).
make-q-class
(macro).
math
(macro).
predicate
(macro).
pwr-of-2?
(function).
q-class-name
(function).
ranged-fp
(class).
symb
(function).
Packages are listed by definition order.
fixed
common-lisp
.
*rounding-method*
(special variable).
decimal-fixedp
(generic function).
defdecimal
(macro).
defdelta
(macro).
delta
(generic function).
f*
(generic function).
f+
(generic function).
f-
(generic function).
f/
(generic function).
f/=
(generic function).
f<
(generic function).
f<=
(generic function).
f=
(generic function).
f>
(generic function).
f>=
(generic function).
fixedp
(generic function).
fp
(class).
install-q-reader
(function).
ordinary-fixedp
(generic function).
ordinary-fp
(class).
q-reader-error
(condition).
q-reader-invalid-value
(condition).
q-reader-non-symbol
(condition).
q-reader-unknown-fixed-type
(condition).
ranged-fixedp
(generic function).
size
(generic function).
small
(generic function).
%defdelta
(macro).
+whitespace+
(constant).
clear-whitespace
(function).
decimal-fp
(class).
make-q-class
(macro).
math
(macro).
predicate
(macro).
pwr-of-2?
(function).
q-class-name
(function).
q-ratio
(function).
q-reader
(function).
q-reader-invalid-value-message
(generic reader).
ranged-fp
(class).
ratio-meets-spec?
(function).
read-decimal-q
(function).
read-decimal-q-decimal
(function).
read-integer
(function).
read-ordinary-q
(function).
read-ordinary-q-decimal
(function).
read-q-character-spec
(function).
read-q-decimal
(function).
read-sign
(function).
read-user-decimal
(function).
read-user-ordinary
(function).
spec-small
(function).
symb
(function).
unknown-fixed-type-symbol
(generic reader).
Definitions are sorted by export status, category, package, and then by lexicographic order.
#’round or #’truncate or similar functions will be used to handle precision loss.
A short-cut for defining a base-10 decimal type, that also happens to be printed correctly.
Define a fixed point class named NAME which supports a resolution
of DELTA. The class maintains the value as an
(INTEGER LOW-RANGE HIGH-RANGE) where the LOW-RANGE and HIGH_RANGE are
determined to provide an engineering-unit value within the range of low
to high.
When SMALL is provided, the resolution of the type is defined to
be exactly SMALL. When only DELTA is provided, the resolution of
the type is defined to be the negative power of 2 that is no larger
than DELTA.
e.g. (defdelta foo 1/10) yields a SMALL value of 1/16.
(defdelta foo 1/10 :small 1/10) yields a SMALL value of 1/10.
This definition also produces a set of related functions and generic
methods for working with the NAME type.
- MAKE-NAME: Creates a NAME type with initial value rounded to the
provided value.
- MAKE-NAME-VALUE: Creates a NAME type with internal value as
provided.
- SET-NAME: A function to set the internal value according to the
engineering unit value provided by rounding.
- SET-NAME-VALUE: A function to set the internal value.
- NAME-VALUE: Accessor (setf’able) for the internal value.
- NAME: Accessor (setf’able) for the engineering unit value.
- Predicates: f= f/= f< f<= f> f>=
- Math operations: f+ f- f* f/
The Q reader can be used to read fixed point types directly with
exact precision. Generic fixed point types will be read directly
as rational values, and are suitable as an argument for a compatible
fixed point type using the MAKE-NAME constructor, where NAME is
the name of the fixed point type.
A generic ordinary fixed point Q spec looks like this:
#Q3 => a type with delta and small of (/ (expt 2 3))
#Q7.8 => a 16 bit (1+ 7 8) signed type with delta and small of (/ (expt 2 8))
A generic decimal fixed point Q spec looks like this:
#QD3 => a type with delta and small of 1/1000
#QD3.1 => a 5 bit type with delta and small of 1/10, i.e. min == -
Use the Q reader to input fixed-point literals in decimal form. The
rightmost integer in the Q spec defines the number of fractional
bits. The left-most number before the period, if provided, defines
the number of non-fractional bits. The sign bit is implied.
e.g.
#Q3 1.5 => 3/2
#Q3 1.25 => 5/4
#Q3 1.125 => 9/8
#Q3 1.0625 => Error: 1.0625 is not a Q3
The error in the last one is because 1.0625 requires 4 fractional bits
to represent.
#Q4 1.0625 => 17/16
Currently, the reader function returns a ratio representing the
decimal value read.
Is the object a decimal fixed point type.
decimal-fp
)) ¶Return the delta used by fp.
Multiply all fixed-point arguments of a single
type. The first value returned is the resultant fixed-point value,
the second value is the residual.
Sum all fixed-point arguments of a single type.
Subtract all fixed-point arguments of a single type
from the first value when more than one value are provided. If only
a single value is provided, negate that value.
Divide the first value by the rest, or perform the
inverse operation if a single value is provided.
The first value returned is the resultant fixed-point value, the
second value is the residual.
Determine if fixed-point values of the same type are not equal.
Determine if fixed-point values of the same type are in ascending order.
Determine if fixed-point values of the same type are in ascending-or-equal order.
Determine if fixed-point values of the same type are equal.
Determine if fixed-point values of the same type are in descending order.
Determine if fixed-point values of the same type are in descending-or-equal order.
Is the object an fixed point type.
Is the object an ordinary fixed point type.
ordinary-fp
)) ¶Is the object a ranged fixed point type.
Return the number of bits required by a ranged fp. An fp type defined with zero or one limits returns :INFINITY.
Return the scaling factor used by fp.
error
.
:message
This slot is read-only.
common-lisp
.
:symbol
This slot is read-only.
Do the work of creating the delta type.
Is a number a power of 2? If so, return that power.
A generic Q spec looks like this:
#Q3 => a type with delta and small of (/ (expt 2 3))
Return value (cons nil 3)
#Q7.8 => a 16 bit (1+ 7 8) signed type with delta and small of (/ (expt 2 8))
Return value (cons 7 8)
Alternatively, a generic Q spec could be in decimal form:
#QD2 123.45 => 12345/100
Read a decimal #QD with infinite precision, or #QDvalue where value is some integer defining the number of digits of precision.
Read a decimal #QD with infinite precision, or #QDvalue where value is some integer defining the number of digits of precision.
Read a base-10 integer, leaving whitespace or other characters on the stream. The integer is terminated by any non-digit-char. Return is (values sign result power terminating-char)
Read an ordinary fixed-point value.
Read an ordinary fixed-point value.
Read a user-specified Q type, or the D for a decimal type. If the first character read is #D or #d, followed by a digit character, then the result is ’D, indicating a decimal type.
Otherwise, the character is unread, the READ function is called, returning the resultant symbol
This reads the integer and fraction into the car and cdr of a cons. The second value is a cons of the count of digits in the first and second integers.
Given a cons of a Q spec (see Q-READER), return the inverse of the small-value of a corresponding fixed type.
q-reader-invalid-value
)) ¶q-reader-unknown-fixed-type
)) ¶Jump to: | %
C D F G I M O P Q R S U |
---|
Jump to: | %
C D F G I M O P Q R S U |
---|
Jump to: | *
+
C M S V |
---|
Jump to: | *
+
C M S V |
---|
Jump to: | C D F M O P Q R S |
---|
Jump to: | C D F M O P Q R S |
---|