;;; -*- Mode:gate; Fonts:(HL12 HL12I HL12B CPTFONTB HL12BI HL12B HL12I ) -*- =Node: Complex Number Functions =Text: 3COMPLEX NUMBER FUNCTIONS* See also the predicates 2realp* and 2complexp* (4(PRIMOBJTYPE-1)Data Type Predicates*). 3complex* 1x* &optional 1y* Returns the complex number whose real part is 1x* and whose imaginary part is 1y*. If 1x* is rational and 1y* is zero or omitted, the value is 1x*, and not a complex number at all. If 1x* is a float and 1y* is zero or omitted, of if 1y* is a floating zero, the result is a complexnum whose imaginary part is zero. 3realpart* 1z* Returns the real part of the number 1z*. If 1z* is real, this is the same as 1z*. 3imagpart* 1z* Returns the imaginary part of the number 1z*. If 1z* is real, this is zero. 3conjugate* 1z* Returns the complex conjugate of the number 1z*. If 1z* is real, this is the same as 1z*. 3phase* 1z* Returns the phase angle of the complex number 1z* in its polar form. This is the angle from the positive 1x* axis to the ray from the origin through 1z*. The value is always in the interval 2(-,* 2]*. 3(phase -4) => * 3(phase -4-.0001i) *is just over 2-*. 3(phase 0) => 0 *(an arbitrary choice) 3cis* 1angle* Returns the complex number of unit magnitude whose phase is 1angle*. This is equal to 2(complex (cos 1angle*) (sin 1angle*))*. 1angle* must be real. 3signum* 1z* Returns a number with unit magnitude and the same type and phase as 1z*. If 1z* is zero, the value is zero. If 1z* is real, the value is 2=* to 21* or 2-1*; it may be a float, however. =Node: Transcendental Functions =Text: 3TRANSCENDENTAL FUNCTIONS* These functions are only for floating-point arguments; if given an integer they convert it to a float. If given a short float, they return a short float. 3pi* 1Constant* The value of 2*, as a full-size float. 3exp* 1x* Returns 1e* raised to the 1x*'th power, where 1e* is the base of natural logarithms. 3log* 1x* &optional 1base* Returns the logarithm of 1x* to base 1base*. 1base* defaults to 1e*. When 1base* is 1e*, the imaginary part of the value is in the interval 2(-, ]*; for negative real 1x*, the value has imaginary part 2*. If 1base* is specified, the result is 3(// (log 1x*) (log 1base*)) sys:zero-log* (3sys:arithmetic-error* 3error*) 1Condition* This is signaled when the argument to 2log* is zero. 3sin* 1x* 3cos* 1x* 3tan* 1x* Return, respectively, the sine, cosine and tangent of 1x*, where 1x* is expressed in radians. 1x* may be complex. 3sind* 1x* 3cosd* 1x* 3tand* 1x* Return, respectively, the sine, cosine and tangent of 1x*, where 1x* is expressed in degrees. 3asin* 1x* 3acos* 1x* Returns the angle (in radians) whose sine (respectively, cosine) is 1x*. The real part of the result of 2asin* is between 2-/2* and 2/2*; 2acos* and 2asin* of any given argument always add up to 2/2*. 3atan* 1y* &optional 1x* If only 1y* is given, the value is the angle, in radians, whose tangent is 1y*. The real part of the result is between zero and 2-*. If 1x* is also given, both arguments must be real, and the value is an angle, in radians, whose tangent is 1y/x*. However, the signs of the two arguments are used to choose between two angles which differ by 2* and have the same tangent. The one chosen is the angle from the 1x*-axis counterclockwise to the line from the origin to the point (1x*, 1y*). 2atan* always returns a non-negative number between zero and 22*. 3atan2* 1y* &optional 1x* 3cli:atan* 1y* &optional 1x* Like 2atan* but always returns a value whose real part is between 2-/2* and 2/2*. The value is either the same as the value of 2atan* or differs from it by 2*. 2atan2* is the traditional name of this function. In Common Lisp it is called 2atan*; it is documented as 2cli:atan* since the name 2atan* has a different meaning in traditional syntax. 3sinh* 1x* 3cosh* 1x* 3tanh* 1x* 3asinh* 1x* 3acosh* 1x* 3atanh* 1x* The hyperbolic and inverse hyperbolic functions. =Node: Numeric Type Conversions =Text: 3NUMERIC TYPE CONVERSIONS* These functions are provided to allow specific conversions of data types to be forced, when desired. 3float* 1number* &optional 1float* Converts 1number* to a floating point number and returns it. If 1float* is specified, the result is of the same floating point format as 1float*. If 1number* is a float of a different format then it is converted. If 1float* is omitted, then 1number* is converted to a single-float unless it is already a floating point number. A complex number is converted to one whose real and imaginary parts are full-size floats unless they are already both floats. 3small-float* 1x* 3short-float* 1x* Converts any kind of real number to a short-float. A complex number is converted to one whose real and imaginary parts are short floats. The two names are synonymous. 3numerator* 1x* Returns the numerator of the rational number 1x*. If 1x* is an integer, the value equals 1x*. If 1x* is not an integer or ratio, an error is signaled. 3denominator* 1x* Returns the denominator of the rational number 1x*. If 1x* is an integer, the value is 21*. If 1x* is not an integer or ratio, an error is signaled. 3rational* 1x* Converts 1x* to a rational number. If 1x* is an integer or a ratio, it is returned unchanged. If it is a floating point number, it is regarded as an exact fraction whose numerator is the mantissa and whose denominator is a power of two. For any other argument, an error is signaled. 3rationalize* 1x* &optional 1precision* Returns a rational approximation to 1x*. If there is only one argument, and it is an integer or a ratio, it is returned unchanged. If the argument is a floating point number, a rational number is returned which, if converted to a floating point number, would produce the original argument. Of all such rational numbers, the one chosen has the smallest numerator and denominator. If there are two arguments, the second one specifies how much precision of the first argument should be considered significant. 1precision* can be a positive integer (the number of bits to use), a negative integer (the number of bits to drop at the end), or a floating point number (minus its exponent is the number of bits to use). If there are two arguments and the first is rational, the value is a ``simpler'' rational which approximates it. 3fix* 1x* Converts 1x* from a float or ratio to an integer, truncating towards negative infinity. The result is a fixnum or a bignum as appropriate. If 1x* is already a fixnum or a bignum, it is returned unchanged. 2fix* is the same as 2floor* except that 2floor* returns an additional value. 2fix* is semi-obsolete, since the functions 2floor*, 2ceiling*, 2truncate* and 2round* provide four different ways of converting numbers to integers with different kinds of rounding. 3fixr* 1x* 2fixr* is the same as 2round* except that 2round* returns an additional value. 2fixr* is considered obsolete. =Node: Floating Point Numbers =Text: 3FLOATING POINT NUMBERS decode-float* 1float* Returns three values which describe the value of 1float*. The first value is a positive float of the same format having the same mantissa, but with an exponent chosen to make it between 1/2 and 1, less than 1. The second value is the exponent of 1float*: the power of 2 by which the first value needs to be scaled in order to get 1float* back. The third value expresses the sign of 1float*. It is a float of the same format as 1float*, whose value is either 1 or -1. Example: 3(decode-float 38.2)* 3 => 0.596875 6 1.0 integer-decode-float* 1float* Like 2decode-float* except that the first value is scaled so as to make it an integer, and the second value is modified by addition of a constant to compensate. 3(integer-decode-float 38.2)* 3 => #o11431463146 -25. 1.0 scale-float* 1float* 1integer* Multiplies 1float* by 2 raised to the 1integer* power. 1float* can actually be an integer also; it is converted to a float and then scaled. 3(scale-float 0.596875 6) => 38.2* 3(scale-float #o11431463146 -25.) => 38.2 float-sign* 1float1* &optional 1float2* Returns a float whose sign matches that of 1float1* and whose magnitude and format are those of 1float2*. If 1float2* is omitted, 1.0 is used as the magnitude and 1float1*'s format is used. 3(float-sign -1.0s0 35.3) => -35.3* 3(float-sign -1.0s0 35.3s0) => -35.3s0 float-radix* 1float* Defined by Common Lisp to return the radix used for the exponent in the format used for 1float*. On the Lisp Machine, floating point exponents are always powers of 2, so 2float-radix* ignores its argument and always returns 2. 3float-digits* 1float* Returns the number of bits of mantissa in the floating point format which float is an example of. It is 17 for short floats and 31 for full size ones. 3float-precision* 1float* Returns the number of significant figures present in in the mantissa of 1float*. This is always the same as 2(float-digits 1float*)* for normalized numbers, and on the Lisp Machine all floats are normalized, so the two functions are the same. =Node: Logical Operations on Numbers =Text: 3LOGICAL OPERATIONS ON NUMBERS* Except for 2lsh* and 2rot*, these functions operate on both fixnums and bignums. 2lsh* and 2rot* have an inherent word-length limitation and hence only operate on 25-bit fixnums. Negative numbers are operated on in their 2's-complement representation. 3logior* &rest 1integers* Returns the bit-wise logical 1inclusive or* of its arguments. With no arguments, the value is zero, which is the identity for this operation. Example (in octal): 3(logior #o4002 #o67) => #o4067 logand* &rest 1integers* Returns the bit-wise logical 1and* of its arguments. With no arguments, the value is -1, which is the identity for this operation. Examples (in octal): 3(logand #o3456 #o707) => #o406* 3(logand #o3456 #o-100) => #o3400 logxor* &rest 1integers* Returns the bit-wise logical 1exclusive or* of its arguments. With no arguments, the value is zero, which is the identity for this operation. Example (in octal): 3(logxor #o2531 #o7777) => #o5246 logeqv* &rest 1integers* Combines the 1integers* together bitwise using the equivalence operation, which, for two arguments, is defined to result in 1 if the two argument bits are equal. This operation is asociative. With no args, the value is -1, which is an identity for the equivalence operation. Example (in octal): 3(logeqv #o2531 #o7707) => #o-5237 = ...77772541* Non-associative bitwise operations take only two arguments: 3lognand* 1integer1* 1integer2* Returns the bitwise-nand of the two arguments. A bit of the result is 1 if at least one of the corresponding argument bits is 0. 3lognor* 1integer1* 1integer2* Returns the bitwise-nor of the two arguments. A bit of the result is 1 if both of the corresponding argument bits are 0. 3logorc1* 1integer1* 1integer2* Returns the bitwise-or of 1integer2* with the complement of 1integer1*. 3logorc2* 1integer1* 1integer2* Returns the bitwise-or of 1integer1* with the complement of 1integer2*. 3logandc1* 1integer1* 1integer2* Returns the bitwise-and of 1integer2* with the complement of 1integer1*. 3logandc2* 1integer1* 1integer2* Returns the bitwise-and of 1integer1* with the complement of 1integer2*. 3lognot* 1number* Returns the logical complement of 1number*. This is the same as 2logxor*'ing 1number* with -1. Example: 3(lognot #o3456) => #o-3457 boole* 1fn* &rest 1one-or-more-args* 2boole* is the generalization of 2logand*, 2logior*, and 2logxor*. 1fn* should be a fixnum between 0 and 17 octal inclusive; it controls the function which is computed. If the binary representation of 1fn* is 1abcd* (1a* is the most significant bit, 1d* the least) then the truth table for the Boolean operation is as follows: 3 y* 3 | 0 1* 3---------* 3 0| a c* 3x |* 3 1| b d* If 2boole* has more than three arguments, it is associated left to right; thus, 3(boole fn x y z) = (boole fn (boole fn x y) z)* With two arguments, the result of 2boole* is simply its second argument. At least two arguments are required. Examples: 3(boole 1 x y) = (logand x y)* 3(boole 6 x y) = (logxor x y)* 3(boole 2 x y) = (logand (lognot x) y)* 2logand*, 2logior*, and so on are usually preferred over the equivalent forms of 2boole*. 2boole* is useful when the operation to be performed is not constant. 3boole-ior* 1Constant* 3boole-and* 1Constant* 3boole-xor* 1Constant* 3boole-eqv* 1Constant* 3boole-nand* 1Constant* 3boole-nor* 1Constant* 3boole-orc1* 1Constant* 3boole-orc2* 1Constant* 3boole-andc1* 1Constant* 3boole-andc2* 1Constant* The 2boole* opcodes that correspond to the functions 2logior*, 2logand*, etc. 3boole-clr* 1Constant* 3boole-set* 1Constant* 3boole-1* 1Constant* 3boole-2* 1Constant* The 2boole* opcodes for the four trivial operations. Respectively, they are those which always return zero, always return one, always return the first argument, and always return the second argument. 3bit-test* 1x* 1y* 3logtest* 1x* 1y* 2bit-test* is a predicate which returns 2t* if any of the bits designated by the 1's in 1x* are 1's in 1y*. 2bit-test* is implemented as a macro which expands as follows: 3(bit-test 1x* 1y*) ==> (not (zerop (logand 1x* 1y*)))* 2logtest* is the Common Lisp name for this function. 3lsh* 1x* 1y* Returns 1x* shifted left 1y* bits if 1y* is positive or zero, or 1x* shifted right 2|1y*|* bits if 1y* is negative. Zero bits are shifted in (at either end) to fill unused positions. 1x* and 1y* must be fixnums. (In some applications you may find 2ash* useful for shifting bignums; see below.) Examples: 3(lsh 4 1) => #o10* 3(lsh #o14 -2) => 3* 3(lsh -1 1) => -2 ash* 1x* 1y* Shifts 1x* arithmetically left 1y* bits if 1y* is positive, or right 1-y* bits if 1y* is negative. Unused positions are filled by zeroes from the right, and by copies of the sign bit from the left. Thus, unlike 2lsh*, the sign of the result is always the same as the sign of 1x*. If 1x* is a fixnum or a bignum, this is a shifting operation. If 1x* is a float, this does scaling (multiplication by a power of two), rather than actually shifting any bits. 3rot* 1x* 1y* Returns 1x* rotated left 1y* bits if 1y* is positive or zero, or 1x* rotated right 2|1y*|* bits if 1y* is negative. The rotation considers 1x* as a 25-bit number (unlike Maclisp, which considers 1x* to be a 36-bit number in both the pdp-10 and Multics implementations). 1x* and 1y* must be fixnums. (There is no function for rotating bignums.) Examples: 3(rot 1 2) => 4* 3(rot 1 -2) => #o20000000* 3(rot -1 7) => -1* 3(rot #o15 25.) => #o15 logcount* 1integer* Returns the number of 1 bits in 1integer*, if it is positive. Returns the number of 0 bits in 1integer*, if it is negative. (There are infinitely many 1 bits in a negative integer.) 3(logcount #o15) => 3* 3(logcount #o-15) => 2 integer-length* 1integer* The minimum number of bits (aside from sign) needed to represent 1integer* in two's complement. This is the same as 2haulong* for positive numbers. 3(integer-length 0) => 0* 3(integer-length 7) => 3* 3(integer-length 8) => 4* 3(integer-length -7) => 3* 3(integer-length -8) => 3* 3(integer-length -9) => 4 haulong* 1integer* The same as 2integer-length* of the absolute value of 2integer*. This name exists for Maclisp compatibility only. 3haipart* 1x* 1n* Returns the high 1n* bits of the binary representation of 2|1x*|*, or the low 2-1n** bits if 1n* is negative. 1x* may be a fixnum or a bignum; its sign is ignored. 2haipart* could have been defined by: 3(defun haipart (x n)* 3 (setq x (abs x))* 3 (if (minusp n)* 3 (logand x (1- (ash 1 (- n))))* 3 (ash x (min (- n (haulong x))* 3 0))))* =Node: Byte Manipulation Functions =Text: 3BYTE MANIPULATION FUNCTIONS* Several functions are provided for dealing with an arbitrary-width field of contiguous bits appearing anywhere in an integer (a fixnum or a bignum). Such a contiguous set of bits is called a 1byte*. Note that we are not using the term 1byte* to mean eight bits, but rather any number of bits within a number. These functions use numbers called 1byte specifiers* to designate a specific byte position within any word. A byte specifier contains two pieces of information: the size of the byte, and the position of the byte. The position is expressed as the number of least significant bits which are not included in the byte. A position of zero means that the byte is at the right (least significant) end of the number. The maximum value of the size is 24, since a byte must fit in a fixnum although bytes can be loaded from and deposited into bignums. (Bytes are always positive numbers.) Byte specifiers are represented as fixnums whose two lowest octal digits represent the 1size* of the byte, and whose higher (usually two, but sometimes more) octal digits represent the 1position* of the byte within a number. For example, the byte-specifier #o0010 (i.e. 10 octal) refers to the lowest eight bits of a word, and the byte-specifier #o1010 refers to the next eight bits. The format of byte-specifiers is taken from the pdp-10 byte instructions. Much old code contains byte specifiers written explicitly as octal numbers. It is cleaner to construct byte specifiers using 2byte* instead. Decomposition of byte specifiers should always be done with 2byte-position* and 2byte-size*, as at some time in the future other kinds of byte specifiers may be created to refer to fields whose size is greater than #o77. 3byte* 1size* 1position* Returns a byte specifier for the byte of 1size* bits, positioned to exclude the 1position* least significant bits. This byte specifier can be passed as the first argument to 2ldb*, 2dpb*, 2%logldb*, 2%logdpb*, 2mask-field*, 2%p-ldb*, 2%p-ldb-offset*, and so on. 3byte-position* 1byte-spec* 3byte-size* 1byte-spec* Return, respectively, the size and the position of 1byte-spec*. It is always true that 3(byte (byte-size 1byte-spec*) (byte-position 1byte-spec*))* equals 1byte-spec*. 3ldb* 1byte-spec* 1integer* Extracts a byte from 1integer* according to 1byte-soec*. The contents of this byte are returned right-justified in a fixnum. The name of the function, 2ldb*, means `load byte'. 1integer* may be a fixnum or a bignum. The returned value is always a fixnum. Example: 3(ldb (byte 6 3) #o4567) => #o56 load-byte* 1integer* 1position* 1size* This is like 2ldb* except that instead of using a byte specifier, the 1position* and 1size* are passed as separate arguments. The argument order is not analogous to that of 2ldb* so that 2load-byte* can be compatible with Maclisp. 3ldb-test* 1byte-spec* 1integer* 2ldb-test* is a predicate which returns 2t* if any of the bits designated by the byte specifier 1byte-spec* are 1's in 1integer*. That is, it returns 2t* if the designated field is non-zero. 2ldb-test* is implemented as a macro which expands as follows: 3(ldb-test 1byte-spec* 1integer*) ==> (not (zerop (ldb 1byte-spec* 1integer*))) logbitp* 1index* 1integer* 2t* if the bit 1index* up from the least significant in 1integer* is a 1. This is equivalent to 2(ldb-test* 2(byte 1index* 1) 1integer*)*. 3mask-field* 1byte-spec* 1fixnum* This is similar to 2ldb*; however, the specified byte of 1fixnum* is positioned in the same byte of the returned value. The returned value is zero outside of that byte. 1fixnum* must be a fixnum. Example: 3(mask-field (byte 6 3) #o4567) => #o560 dpb* 1byte* 1byte-spec* 1integer* Returns a number which is the same as 1integer* except in the bits specified by 1byte-spec*. The low bits of 1byte*, appropriately many, are placed in those bits. 1byte* is interpreted as being right-justified, as if it were the result of 2ldb*. 1integer* may be a fixnum or a bignum. The name means `deposit byte'. Example: 3(dpb #o23 (byte 6 3) #o4567) => #o4237 deposit-byte* 1integer* 1position* 1size* 1byte* This is like 2dpb* except that instead of using a byte specifier, the 1position* and 1size* are passed as separate arguments. The argument order is not analogous to that of 2dpb* so that 2deposit-byte* can be compatible with Maclisp. 3deposit-field* 1byte* 1byte-spec* 1fixnum* This is like 2dpb*, except that 1byte* is not taken to be left-justified; the 1byte-spec* bits of 1byte* are used for the 1byte-spec* bits of the result, with the rest of the bits taken from 1fixnum*. 1fixnum* must be a fixnum. Example: 3(deposit-field #o230 (byte 6 3) #o4567) => #o4237* The behavior of the following two functions depends on the size of fixnums, and so functions using them may not work the same way on future implementations of Zetalisp. Their names start with 2%* because they are more like machine-level subprimitives than the previous functions. 3%logldb* 1byte-spec* 1fixnum* 2%logldb* is like 2ldb* except that it only loads out of fixnums and allows a byte size of 25, i.e. all 25 bits of the fixnum including the sign bit. 3%logdpb* 1byte* 1byte-spec* 1fixnum* 2%logdpb* is like 2dpb* except that it only deposits into fixnums. Using this to change the sign-bit leaves the result as a fixnum, while 2dpb* would produce a bignum result for arithmetic correctness. 2%logdpb* is good for manipulating fixnum bit-masks such as are used in some internal system tables and data-structures. =Node: Random Numbers =Text: 3RANDOM NUMBERS* The functions in this section provide a pseudo-random number generator facility. The basic function you use is 2random*, which returns a new pseudo-random number each time it is called. 3random* &optional 1number* 1random-state* Returns a randomly generated number. If 1number* is specified, the random number is of the same type as 1number* (floating if 1number* is floating, etc.), nonnegative, and less than 1number*. If 1number* is omitted, the result is a randomly chosen fixnum, with all fixnums being equally likely. If 1random-state* is present, it is used and updated in generating the random number. Otherwise, the default random-state (the value of 2*random-state**) is used (and is created if it doesn't already exist). The algorithm is executed inside a 2without-interrupts* (see 4(PROCESSES-1)The Scheduler*) so two processes can use the same random-state without colliding. 3si:random-in-range* 1low* 1high* Returns a random float in the interval [1low*, 1high*). The default random-state is used. A 1random-state* is a named structure of type 2random-state* whose contents control the future actions of the random number generator. Each time you call the function 2random*, it uses (and updates) one random-state. One random-state exists standardly and is used by default. To have several different controllable, resettable sources of random numbers, you can create your own random-states. Random-states print as 3#s(random-state ...1more data*...)* so that they can be read back in. 3random-state-p* 1object* 2t* if 1object* is a random-state. 3*random-state** 1Variable* This random-state is used by default when 2random* is called and the random-state is not explicitly specified. 3make-random-state* &optional 1random-state* Creates and returns a new random-state object. If 1random-state* is 2nil*, the new random-state is a copy of 2*random-state**. If 1random-state* is a random-state, the new one is a copy of that one. If 1random-state* is 2t*, the new random-state is initialized truly randomly (based on the value of 2(time)*). A random-state actually consists of an array of numbers and two pointers into the array. The pointers circulate around the array; each time a random number is requested, both pointers are advanced by one, wrapping around at the end of the array. Thus, the distance forward from the first pointer to the second pointer stays the same, allowing for wraparound. Let the length of the array be 1length* and the distance between the pointers be 1offset*. To generate a new random number, each pointer is set to its old value plus one, modulo 1length*. Then the two elements of the array addressed by the pointers are added together; the sum is stored back into the array at the location where the second pointer points, and is returned as the random number after being normalized into the right range. This algorithm produces well-distributed random numbers if 1length* and 1offset* are chosen carefully, so that the polynomial 1x* 2^* 1length* + 1x* 2^* 1offset* + 1 is irreducible over the mod-2 integers. The system uses 71. and 35. The contents of the array of numbers should be initialized to anything moderately random, to make the algorithm work. The contents get initialized by a simple random number generator, based on a number called the 1seed*. The initial value of the seed is set when the random-state is created, and it can be changed. 3si:random-create-array* 1length* 1offset* 1seed* &optional 1(area* 1nil)* Creates and returns a new random-state according to precise specifications. 1length* is the length of the array. 1offset* is the distance between the pointers and should be an integer less than 1length*. 1seed* is the initial value of the seed, and should be a fixnum. This calls 2si:random-initialize* on the random state before returning it. 3si:random-initialize* 1random-state* &optional 1new-seed* 1random-state* must be a random-state, such as is created by 2si:random-create-array*. If 1new-seed* is provided, it should be a fixnum, and the seed is set to it. 2si:random-initialize* reinitializes the contents of the array from the seed (calling 2random* changes the contents of the array and the pointers, but not the seed). =Node: Information on Numeric Precision =Text: 3INFORMATION ON NUMERIC PRECISION* Common Lisp defines some constants whose values give information in a standard way about the ranges of numbers representable in the individual Lisp implementation. 3most-negative-fixnum* 1Constant* Any integer smaller than this must be a bignum. 3most-positive-fixnum* 1Constant* Any integer larger than this must be a bignum. 3most-positive-short-float* 1Constant* No short float can be greater than this number. 3least-positive-short-float* 1Constant* No positive short float can be closer to zero than this number. 3least-negative-short-float* 1Constant* No negative short float can be closer to zero than this number. 3most-negative-short-float* 1Constant* No short float can be less than this (negative) number. 3most-positive-single-float* 1Constant* 3least-positive-single-float* 1Constant* 3least-negative-single-float* 1Constant* 3most-negative-single-float* 1Constant* Similar to the above, but for full-size floats rather than for short floats. 3most-positive-double-float* 1Constant* 3least-positive-double-float* 1Constant* 3least-negative-double-float* 1Constant* 3most-negative-double-float* 1Constant* 3most-positive-long-float* 1Constant* 3least-positive-long-float* 1Constant* 3least-negative-long-float* 1Constant* 3most-negative-long-float* 1Constant* These are defined by Common Lisp to be similar to the above, but for double-floats and long-floats. On the Lisp Machine, there are no distinct double and long floating formats; they are synonyms for single-floats. So these constants exist but their values are the same as those of 2most-positive-single-float* and so on. 3short-float-epsilon* 1Constant* Smallest positive short float which can be added to 1.0s0 and make a difference. That is, for any short float 1x* less than this, 2(+ 1.0s0 1x*)* equals 1.0s0. 3single-float-epsilon* 1Constant* 3double-float-epsilon* 1Constant* 3long-float-epsilon* 1Constant* Smallest positive float which can be added to 1.0 and make a difference. The three names are synonyms on the Lisp Machine, for reasons explained above. 3short-float-negative-epsilon* 1Constant* Smallest positive short float which can be subtracted from 1.0s0 and make a difference. 3single-float-negative-epsilon* 1Constant* 3double-float-negative-epsilon* 1Constant* 3long-float-negative-epsilon* 1Constant* Smallest positive float which can be subtracted from 1.0 and make a difference. =Node: Arithmetic Ignoring Overflow =Text: 3ARITHMETIC IGNORING OVERFLOW* Sometimes it is desirable to have a form of arithmetic which has no overflow checking (that would produce bignums), and truncates results to the word size of the machine. 3%pointer-plus* 1pointer-1* 1pointer-2* Returns a fixnum which is 1pointer-1* plus 1pointer-2*, modulo what could be stored in the size of the pointer field (currently 25 bits). Arguments other than fixnums are rarely useful, but no type checks are made. 3%pointer-difference* 1pointer-1* 1pointer-2* Returns a fixnum which is 1pointer-1* minus 1pointer-2*. If the arguments are fixnums, rather than true pointers, this provides subtraction modulo what can be stored in the pointer field. 3%pointer-times* 1pointer-1* 1pointer-2* Returns a fixnum which is 1pointer-1* times 1pointer-2*. Arguments other than fixnums are rarely useful, but no type checks are made. The two pointer fields are regarded as signed numbers. =Node: 24-Bit Arithmetic =Text: 324-BIT ARITHMETIC* Sometimes it is useful to have a form of truncating arithmetic with a strictly specified field width which is independent of the range of fixnums permissible on a particular machine. In Zetalisp, this is provided by the following set of functions. Their answers are correct only modulo 2^24. These functions should 1not* be used for efficiency; they are probably less efficient than the functions which 1do* check for overflow. They are intended for algorithms which require this sort of arithmetic, such as hash functions and pseudo-random number generation. 3%24-bit-plus* 1x* 1y* Returns the sum of 1x* and 1y* modulo 2^24. Both arguments must be fixnums. 3%24-bit-difference* 1x* 1y* Returns the difference of 1x* and 1y* modulo 2^24. Both arguments must be fixnums. 3%24-bit-times* 1x* 1y* Returns the product of 1x* and 1y* modulo 2^24. Both arguments must be fixnums. =Node: Double-Precision Arithmetic =Text: 3DOUBLE-PRECISION ARITHMETIC* These peculiar functions are useful in programs that don't want to use bignums for one reason or another. They should usually be avoided, as they are difficult to use and understand, and they depend on special numbers of bits and on the use of twos-complement notation. A double-precision number has 50 bits, of which one is the sign bit. It is represented as two fixnums. The less signficant fixnum conveys 25 signficant bits and is regarded as unsigned (that is, what is normally the sign bit is treated as an ordinary data bit); the more significant fixnum has the same sign as the double-precision number. Only 2%float-double* handles negative double-precision numbers; for the other functions, the more signficant fixnum is always positive and contains only 24 bits of actual data. 3%multiply-fractions* 1num1* 1num2* Returns bits 25 through 48 (the most significant half) of the product of 1num1* and 1num2*, regarded as unsigned integers. If you call this and 2%pointer-times* on the same arguments 1num1* and 1num2*, you can combine the results into a double-precision product. If 1num1* and 1num2* are regarded as two's-complement fractions, -1 2 1num** < 1, 2%multiply-fractions* returns 1/2 of their correct product as a fraction. [The name of this function isn't too great.] 3%divide-double* 1dividend[25:48]* 1dividend[0:24]* 1divisor* Divides the double-precision number given by the first two arguments by the third argument, and returns the single-precision quotient. Causes an error if 1divisor* is zero or if the quotient won't fit in single precision. There are only 24 bits in each half of the number, as neither sign bit is used to convey information. 3%remainder-double* 1dividend[25:48]* 1dividend[0:24]* 1divisor* Divides the double-precision number given by the first two arguments by the third argument, and returns the remainder. Causes an error if 1divisor* is zero. 3%float-double* 1high25* 1low25* 1high25* and 1low25*, which must be fixnums, are concatenated to produce a 50-bit unsigned positive integer. A full-size float containing the same value is constructed and returned. Note that only the 31 most significant bits are retained (after removal of leading zeroes.) This function is mainly for the benefit of 2read*.