Next: , Previous: , Up: syslib   [Index]


12.4 Low level fixnum operations

The following bindings are exported by the library (vicare system $fx). The arguments to these operations must be fixnums. objects fixnums for details on the representation of fixnums.

Predicates

Unsafe Operation: $fxzero? fx

Evaluate to true if fx is zero.

Unsafe Operation: $fxpositive? fx
Unsafe Operation: $fxnegative? fx

Evaluate to true if fx is strictly positive or strictly negative.

Unsafe Operation: $fxnonpositive? fx
Unsafe Operation: $fxnonnegative? fx

Evaluate to true if fx is non–positive or non–negative.

Unsafe Operation: $fxsign fx

Return one of the fixnums +1, -1, 0 representing the sign of fx.

Unsafe Operation: $fxeven? fx
Unsafe Operation: $fxodd? fx

Evaluate to true if fx is even or odd.

Comparison operations

Unsafe Operation: $fx= fx1 fx2

Evaluate to true if the arguments are equal.

Unsafe Operation: $fx=! fx1 fx2

Evaluate to true if the arguments are different.

Unsafe Operation: $fx< fx1 fx2

Evaluate to true if fx1 is less than fx2.

Unsafe Operation: $fx<= fx1 fx2

Evaluate to true if fx1 is less than or equal to fx2.

Unsafe Operation: $fx> fx1 fx2

Evaluate to true if fx1 is greater than fx2.

Unsafe Operation: $fx>= fx1 fx2

Evaluate to true if fx1 is greater than or equal to fx2.

Unsafe Operation: $fxmax fx1 fx2
Unsafe Operation: $fxmin fx1 fx2

Return either the maximum or minimum between the arguments.

Arithmetic operations

Unsafe Operation: $fxadd1 fx

Increment the operand by one and return the result.

Unsafe Operation: $fxsub1 fx

Decrement the operand by one and return the result. The result of this operation is a fixnum, but notice that if fx is (least-fixnum): the result overflows the fixnum capacity and the return value is invalid.

Unsafe Operation: $fx+ fx1 fx2

Sum the operands and return the result. The result of this operatio is a fixnum, but notice that it could overflow the fixnum capacity.

Unsafe Operation: $fx- fx
Unsafe Operation: $fx- fx1 fx2

With one operand: return fx negated. With two operands: subtract the operands and return the result. The result of this operation is a fixnum, but notice that it could overflow the fixnum capacity and the return value would be invalid.

Also with a single argument, knowing that (- (least-fixnum)) is a bignum, if fx is (least-fixnum) the result overflows the fixnum capacity and the return value is invalid.

With two arguments: if fx1 is zero and fx2 is (least-fixnum) the result overflows the fixnum capacity and the return value is invalid.

Unsafe Operation: $fx* fx1 fx2

Multiply the operands and return the result. The result of this operation is a fixnum, but notice that if one operand is -1 and the other is (least-fixnum): the result overflows the fixnum capacity and the return value is invalid.

Unsafe Operation: $fxdiv fx1 fx2
Unsafe Operation: $fxdiv0 fx1 fx2
Unsafe Operation: $fxmod fx1 fx2
Unsafe Operation: $fxmod0 fx1 fx2
Unsafe Operation: $fxdiv-and-mod fx1 fx2
Unsafe Operation: $fxdiv0-and-mod0 fx1 fx2

Perform the number theoretic division.

(import (rnrs)
  (vicare system $fx))

($fxmod +12 +12)        ⇒ 0
($fxmod +12 -12)        ⇒ 0
($fxmod -12 +12)        ⇒ 0
($fxmod -12 -12)        ⇒ 0

($fxmod +12 +3)         ⇒ 0
($fxmod +12 -3)         ⇒ 0
($fxmod -12 +3)         ⇒ 0
($fxmod -12 -3)         ⇒ 0

($fxmod +12 +4)         ⇒ 0
($fxmod +12 -4)         ⇒ 0
($fxmod -12 +4)         ⇒ 0
($fxmod -12 -4)         ⇒ 0

($fxmod +12 +5)         ⇒ +2
($fxmod +12 -5)         ⇒ +2
($fxmod -12 +5)         ⇒ +3
($fxmod -12 -5)         ⇒ +3

($fxmod +12 +7)         ⇒ +5
($fxmod +12 -7)         ⇒ +5
($fxmod -12 +7)         ⇒ +2
($fxmod -12 -7)         ⇒ +2

($fxmod +12 +24)        ⇒ +12
($fxmod +12 -24)        ⇒ +12
($fxmod -12 +24)        ⇒ +12
($fxmod -12 -24)        ⇒ +12

($fxmod +12 +20)        ⇒ +12
($fxmod +12 -20)        ⇒ +12
($fxmod -12 +20)        ⇒ +8
($fxmod -12 -20)        ⇒ +8
Unsafe Operation: $fxquotient fx1 fx2

Compute the quotient between the operands and return the result. The result of this operation is a fixnum, but notice that:

Unsafe Operation: $fxmodulo fx1 fx2

Compute the modulo between the operands and return the result. The result of this operation can be a fixnum or bignum.

(import (rnrs)
  (vicare system $fx))

($fxmodulo +12 +12)     ⇒ 0
($fxmodulo +12 -12)     ⇒ 0
($fxmodulo -12 +12)     ⇒ 0
($fxmodulo -12 -12)     ⇒ 0

($fxmodulo +12 +3)      ⇒ 0
($fxmodulo +12 -3)      ⇒ 0
($fxmodulo -12 +3)      ⇒ 0
($fxmodulo -12 -3)      ⇒ 0

($fxmodulo +12 +4)      ⇒ 0
($fxmodulo +12 -4)      ⇒ 0
($fxmodulo -12 +4)      ⇒ 0
($fxmodulo -12 -4)      ⇒ 0

($fxmodulo +12 +5)      ⇒ +2
($fxmodulo +12 -5)      ⇒ -3
($fxmodulo -12 +5)      ⇒ +3
($fxmodulo -12 -5)      ⇒ -2

($fxmodulo +12 +7)      ⇒ +5
($fxmodulo +12 -7)      ⇒ -2
($fxmodulo -12 +7)      ⇒ +2
($fxmodulo -12 -7)      ⇒ -5

($fxmodulo +12 +24)     ⇒ +12
($fxmodulo +12 -24)     ⇒ -12
($fxmodulo -12 +24)     ⇒ +12
($fxmodulo -12 -24)     ⇒ -12

($fxmodulo +12 +20)     ⇒ +12
($fxmodulo +12 -20)     ⇒  -8
($fxmodulo -12 +20)     ⇒  +8
($fxmodulo -12 -20)     ⇒ -12
Unsafe Operation: $fxabs fx

Return the absolute value of fx as a fixnum. When fx is (least-fixnum): its absolute value would be a fixnum, in which case this operation raises an implementation restriction violation.

To compute the general absolute value without overflow we must use abs or $abs-fixnum.

Bitwise logic operations

Unsafe Operation: $fxnot fx

Perform the bitwise NOT on the operand and return the result.

Unsafe Operation: $fxand fx1 fx2

Perform the bitwise AND on the operands and return the result.

Unsafe Operation: $fxior fx1 fx2

Perform the bitwise inclusive OR on the operands and return the result.

Unsafe Operation: $fxxor fx1 fx2

Perform the bitwise exclusive OR on the operands and return the result.

Unsafe Operation: $fxif fx1 fx2 fx3

Return the fixnum that is the bit–wise “if” of the two’s complement representations of its arguments, i.e. for each bit, if it is 1 in fx1, the corresponding bit in fx2 becomes the value of the corresponding bit in the result, and if it is 0, the corresponding bit in fx3 becomes the corresponding bit in the value of the result.

Other bitwise operations

Unsafe Operation: $fxsll fx1 fx2

Perform bitwise shift left of fx1 by fx2 positions and return the result.

Unsafe Operation: $fxsra fx1 fx2

Perform bitwise shift right of fx1 by fx2 positions and return the result.

Unsafe Operation: $fxcopy-bit fx1 fx2 fx3

Unsafe version of fxcopy-bit.

Unsafe Operation: $fxcopy-bit-field fx1 fx2 fx3 fx4

Unsafe version of fxcopy-bit-field.

Unsafe Operation: $fxrotate-bit-field fx1 fx2 fx3 fx4

Unsafe version of fxrotate-bit-field.

Unsafe Operation: $fxbit-field fx1 fx2 fx3

Unsafe version of fxbit-field.

Conversion operations

Unsafe Operation: $fixnum->string fx base

Return a string object representing fx in base. base must be one among: 2, 8, 10, 16.

Unsafe Operation: $fixnum->char fx

Return a new character value whose code point equals fx.

Unsafe Operation: $char->fixnum ch

Return a fixnum representing the code point of the operand.

Unsafe Operation: $fixnum->flonum fx

Convert the fixnum operand into a flonum and return a reference to the result.

Miscellaneous operations

Unsafe Operation: $fxinthash fx

Evaluate to a fixnum which can be used as hash value.

NOTE This appears to be unused in the source.


Next: , Previous: , Up: syslib   [Index]