R6RS 3.4 Implementation requirements reads
... Potentially inexact operations such as
sqrt
, when applied to exact arguments, should produce exact answers whenever possible (for example the square root of an exact 4 ought to be an exact 2).
(1) Does this mean that (* 0 2.2)
must produce 0.0
but never 0
as result?
However, this is not required. ...
(2) Does this mean that (/ 4 2)
may also produce 2.0 as result?
(3) And are there implementations that provide integer roots in this manner? How do I get the functionality of integer square roots in general? (Here is the index) (Please no recursive/iterative implementation)
R6RS has
exact-integer-sqrt
. It returns two values, the square root and the remainder. You can discard the second value if you want.Implementations are allowed (but not required) to consider
(* 0 x)
(multiplying anything by an exact zero) to be exact zero for any x. See the R6RS description of the*
procedure.