*(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

πŸ’… NAME πŸ’…

okay so this page is about *, fx*, and fl* β€” the multiplication girlies of the Scheme Programmer's Manual (that's the *(3scm) moment, iykyk). slay ✨

πŸ“š LIBRARY πŸ“š

bestie, import the flavor you need:

(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS
(import (rnrs arithmetic fixnums))  ;R6RS, fx*
(import (rnrs arithmetic flonums))  ;R6RS, fl*
(import (scheme r5rs))              ;R7RS
(import (scheme base))              ;R7RS

🫢 SYNOPSIS 🫢

(* number ...)
(fl* fl1...)                        ;R6RS
(fx* fx1 fx2)                       ;R6RS

🌸 DESCRIPTION 🌸

This procedure returns the product of its arguments. periodt πŸ’–

Fixnum variant

An exception with condition type &implementation-restriction is raised if the product is not a fixnum. no cap, that's the rule.

Flonum variant

In general, this procedure should return the flonum that best approximates the mathematical product. For implementations that represent flonums using IEEE binary floating point, the meaning of "best" is defined by the IEEE standards.

(fl+ +inf.0 -inf.0) => +nan.0
(fl+ +nan.0 fl)     => +nan.0
(fl* +nan.0 fl)     => +nan.0

πŸ‘‘ IMPLEMENTATION NOTES πŸ‘‘

Chez Scheme β€” An exact zero is returned when any of the arguments to * is an exact zero. iconic behavior πŸ’…

πŸ’– RETURN VALUES πŸ’–

Returns one value, which is a number object.

For the generic variant, the return value is exact if all arguments are exact. If any argument is inexact then the result is inexact, unless one of the arguments is an exact zero, in which case the return value can optionally be an exact zero.

Non-R6RS implementations may be missing parts of the numeric tower and can thus resort to inexact numbers even for exact computations. lowkey important, bestie.

πŸŽ€ EXAMPLES πŸŽ€

; Examples apply to R6RS. An R5RS/R7RS implementation
; might e.g. not provide rational or complex numbers.
(* 6 7)           => 42
(* 2 1/3)         => 2/3
(* 2 1.57)        => 3.14
(* 5 1+2i)        => 5+10i

; Examples from R6RS
(* 4)             => 4
(*)               => 1
(* 5 +inf.0)      => +inf.0
(* -5 +inf.0)     => -inf.0
(* +inf.0 +inf.0) => +inf.0
(* +inf.0 -inf.0) => -inf.0
(* 0 +inf.0)      => 0 or +nan.0
(* 0 +nan.0)      => 0 or +nan.0
(* 1.0 0)         => 0 or 0.0

🌈 COMPATIBILITY 🌈

R6RS is the only RnRS report on Scheme to require a full implementation of the numeric tower. In R7RS code, the feature identifiers exact-closed, exact-complex, ieee-float, and ratios should be consulted before performing arithmetic that requires one of these features.

In R7RS, (* 0 +inf.0) may return 0, or +nan.0, or report that inexact numbers are not supported, or report that non-rational real numbers are not supported, or fail silently or noisily in other implementation-specific ways. πŸ’€ the drama is real.

😭 ERRORS 😭

This procedure can raise exceptions with the following condition types:

  • &assertion (R6RS) β€” An argument was outside its domain.
  • &implementation-restriction (R6RS) β€” May be raised when applied to mixed non-rational real and non-real complex arguments. Otherwise an unspecified number object is returned. Raised by the fixnum variant if the mathematically correct result is not a fixnum.
  • R7RS β€” The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.
fail catastrophically?? not the villain arc 😭

πŸ¦‹ SEE ALSO πŸ¦‹

  • +(3scm)

⭐ STANDARDS ⭐

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

πŸ₯° AUTHORS πŸ₯°

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/.


mwah πŸ’‹ β€” this is *(3scm) from scheme-manpages, and the footer date is 2020-10-18. bye bestie, go multiply something cute 🫢✨

πŸ“¦ where this page comes from