IEEE 754 floating-point arithmetic, homed on the Float class.
Literal syntax: 3.14. The generic operators dispatch float operands
through the type ops; mixed operands resolve by the from-relation.
float-splitint->floatfloat-fracfloat-first-fracfloat-int-digitsfloat-neg-intlibm-fnstr->floatfloatfloat?float-off-addf-subf-mulf-divf-modf-ltf-eqfsinfcosfsqrtfatan2piensure-floatfloat-typenumber?Test whether a value is a number (now including floats).
Parameters:
ANY — Value to testReturns: BOOL — True if x is a number
Examples:
(list (number? 2.5) (number? "2.5")) => (#t #f)Float(Float float? x)Test whether a value is a float.
Parameters:
ANY — Value to testReturns: BOOL — True if x is a float
Examples:
(list (Float float? 2.5) (Float float? 2)) => (#t #f)(Float inexact? x)Test whether a value is inexact. Equivalent to float?.
Parameters:
ANY — Value to testReturns: BOOL — True if x is a float
Examples:
(Float inexact? 0.5) => #t(Float integer? x)Test whether a value is an integer (the pre-float number? predicate).
Parameters:
ANY — Value to testReturns: BOOL — True if x is a native integer
Examples:
(list (Float integer? 3) (Float integer? 3.0)) => (#t #f)(Float real? x)Test whether a value is a real number (numbers minus complexes).
Parameters:
ANY — Value to testReturns: BOOL — True if x is real
Examples:
(Float real? 2.5) => #t(Float bits->str bits)Render a raw IEEE 754 bit pattern as its decimal string – FFI plumbing; value-level work wants (Float from) / the printer.
Parameters:
ANY — IEEE 754 double bit pattern: an INTEGER, or a VECTOR of two words on a 4-byte wordReturns: STRING — Decimal string representation
Examples:
(Float bits->str (Float int->bits 3)) => "3.0"(Float bits->int bits)Truncate a raw IEEE 754 bit pattern to a machine integer – FFI plumbing; value-level work wants (Float ->int).
Parameters:
ANY — IEEE 754 double bit pattern: an INTEGER, or a VECTOR of two words on a 4-byte wordReturns: INTEGER — Truncated integer value
Examples:
(Float bits->int (Float str->bits "2.5")) => 2(Float int->bits n)The IEEE 754 bit pattern of an integer’s double value – FFI plumbing, NOT a float constructor; (Float from) builds instances.
Parameters:
INTEGER — Integer valueReturns: ANY — IEEE 754 double bit pattern: an INTEGER, or a VECTOR of two words on a 4-byte word
Examples:
(Float bits->str (Float int->bits 1)) => "1.0"(Float str->bits s)The IEEE 754 bit pattern of a decimal string’s double value – FFI plumbing, NOT a parser-to-instance; (Float from) builds instances (the old from-str name claimed FLOAT and returned bits, #66).
Parameters:
STRING — Decimal string to parseReturns: ANY — IEEE 754 double bit pattern: an INTEGER, or a VECTOR of two words on a 4-byte word
Examples:
(= (Float str->bits "1.0") (Float int->bits 1)) => #t(Float from x)Construct a float from any convertible value, through the conversion catalogue – the generic value door (was exact->inexact, #357). Raises a label ‘type when nothing converts.
Parameters:
ANY — An exact number (int, bigint, rational), a numeric string, or a float (identity)Returns: FLOAT — Float instance
Examples:
(Float from 3) => 3.0(Float ->int x)Convert an inexact float to an exact integer by truncation.
Parameters:
FLOAT — Float value (machine ints pass through)Returns: INTEGER — Truncated integer value
Examples:
(Float ->int -2.7) => -2(Float + a b)Add two floats (other numerics promote).
Parameters:
NUMBER — First operandNUMBER — Second operandReturns: FLOAT — Sum
Examples:
(Float + 1 0.5) => 1.5(Float - a b)Subtract two floats (other numerics promote).
Parameters:
NUMBER — First operandNUMBER — Second operandReturns: FLOAT — Difference
Examples:
(Float - 3 0.5) => 2.5(Float * a b)Multiply two floats (other numerics promote).
Parameters:
NUMBER — First operandNUMBER — Second operandReturns: FLOAT — Product
Examples:
(Float * 2 1.25) => 2.5(Float / a b)Divide two floats (other numerics promote).
Parameters:
NUMBER — DividendNUMBER — DivisorReturns: FLOAT — Quotient
Examples:
(Float / 1 4) => 0.25(Float < a b)Test whether a is less than b (other numerics promote).
Parameters:
NUMBER — Left operandNUMBER — Right operandReturns: BOOL — True if a < b
Examples:
(Float < 1 1.5) => #t(Float = a b)Test whether a equals b (other numerics promote).
Parameters:
NUMBER — Left operandNUMBER — Right operandReturns: BOOL — True if a equals b
Examples:
(Float = 2 2.0) => #t(Float sin x)Compute the sine of a float.
Parameters:
FLOAT — Angle in radiansReturns: FLOAT — Sine of x
Examples:
(Float sin 0.0) => 0.0(Float cos x)Compute the cosine of a float.
Parameters:
FLOAT — Angle in radiansReturns: FLOAT — Cosine of x
Examples:
(Float cos 0.0) => 1.0(Float tan x)Compute the tangent of a float.
Parameters:
FLOAT — Angle in radiansReturns: FLOAT — Tangent of x
Examples:
(Float tan 0.0) => 0.0(Float sqrt x)Compute the square root of a float.
Parameters:
FLOAT — Non-negative floatReturns: FLOAT — Square root of x
Examples:
(Float sqrt 16.0) => 4.0(Float exp x)Compute e raised to a power.
Parameters:
FLOAT — ExponentReturns: FLOAT — e raised to the power x
Examples:
(Float exp 0.0) => 1.0(Float log x)Compute the natural logarithm of a float.
Parameters:
FLOAT — Positive floatReturns: FLOAT — Natural logarithm of x
Examples:
(Float log 1.0) => 0.0(Float abs x)Compute the absolute value of a float.
Parameters:
FLOAT — Float valueReturns: FLOAT — Absolute value of x
Examples:
(Float abs -2.5) => 2.5(Float floor x)Round a float down to the nearest integer.
Parameters:
FLOAT — Float valueReturns: FLOAT — Largest integer not greater than x
Examples:
(Float floor -2.5) => -3.0(Float ceil x)Round a float up to the nearest integer.
Parameters:
FLOAT — Float valueReturns: FLOAT — Smallest integer not less than x
Examples:
(Float ceil 2.1) => 3.0(Float round x)Round a float to the nearest integer.
Parameters:
FLOAT — Float valueReturns: FLOAT — Nearest integer, ties away from zero
Examples:
(Float round 2.5) => 3.0(Float trunc x)Truncate a float toward zero.
Parameters:
FLOAT — Float valueReturns: FLOAT — Integer part of x
Examples:
(Float trunc -2.7) => -2.0(Float rint x)Round a float to the nearest integer using the current rounding mode.
Parameters:
FLOAT — Float valueReturns: FLOAT — Nearest integer
Examples:
(Float rint 2.5) => 2.0(Float asin x)Compute the arc sine of a float.
Parameters:
FLOAT — Value in [-1, 1]Returns: FLOAT — Arc sine in radians
Examples:
(Float asin 0.0) => 0.0(Float acos x)Compute the arc cosine of a float.
Parameters:
FLOAT — Value in [-1, 1]Returns: FLOAT — Arc cosine in radians
Examples:
(Float acos 1.0) => 0.0(Float atan x)Compute the arc tangent of a float.
Parameters:
FLOAT — Float valueReturns: FLOAT — Arc tangent in radians
Examples:
(Float atan 0.0) => 0.0(Float pow base exponent)Raise a float to a power.
Parameters:
FLOAT — BaseFLOAT — ExponentReturns: FLOAT — base raised to the power exponent
Examples:
(Float pow 2.0 10.0) => 1024.0(Float atan2 y x)Compute the arc tangent of y/x, using signs to determine the quadrant.
Parameters:
FLOAT — Y coordinateFLOAT — X coordinateReturns: FLOAT — Angle in radians
Examples:
(Float atan2 0.0 1.0) => 0.0(Float log2 x)Compute the base-2 logarithm of a float.
Parameters:
FLOAT — Positive floatReturns: FLOAT — log2(x)
(Float log10 x)Compute the base-10 logarithm of a float.
Parameters:
FLOAT — Positive floatReturns: FLOAT — log10(x)
(Float hypot x y)Compute sqrt(x^2 + y^2) without intermediate overflow (libm hypot).
Parameters:
FLOAT — First legFLOAT — Second legReturns: FLOAT — The hypotenuse
(Float type)The float type handle, for Convert and Type.
Returns: ATOM — The FLOAT type handle
(Float pi)The circle constant pi, 3.14159265…
Returns: FLOAT — pi
(Float e)Euler’s number e, 2.71828182…
Returns: FLOAT — e
(Float tau)The turn constant tau = 2*pi, 6.28318530…
Returns: FLOAT — tau
(Float nan? x)Is x a float NaN? #f for every non-float (an int is never NaN).
Parameters:
ANY — Value to testReturns: BOOL — #t only for a NaN float
(Float inf? x)Is x a float infinity, either sign? #f for every non-float.
Parameters:
ANY — Value to testReturns: BOOL — #t only for an infinite float
(Float finite? x)Is x a finite number? #t for machine INTs and finite floats; #f for float inf/NaN and for everything else (rational/bigint instances answer through their own classes).
Parameters:
ANY — Value to testReturns: BOOL — #t for machine ints and finite floats