TIP: | 299 |
Title: | Add isqrt() Math Function |
Version: | $Revision: 1.3 $ |
Author: | Kevin B. Kenny <kennykb at acm dot org> |
State: | Final |
Type: | Project |
Tcl-Version: | 8.5 |
Vote: | Done |
Created: | Friday, 24 November 2006 |
Keywords: | Tcl, expression, integer, square root |
This TIP proposes a new expr math function isqrt().
With the advent of large integers, Tcl supports taking the square roots of arguments that lie outside the native floating-point range of the machine. The square roots are returned as floating point numbers if possible. This behaviour is correct when floating-point calculations are intended. There are times, however, when an arbitrary-precision square root is wanted. This root cannot be obtained by evaluating entier(sqrt($n)), because sqrt($n) has already lost precision.
This TIP proposes adding a new math function, isqrt($n), that will return the integer part of the square root of $n to arbitrary precision. The argument $n must be numeric and non-negative; it may be either integer or floating-point.
Tcl Feature Request #1602534 contains a complete reference implementation for the isqrt function.
This document has been placed in the public domain.
[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]
TIP AutoGenerator - written by Donal K. Fellows