[MB] (11-2008) Machine parameters can be computed with the fortran routine DLAMCH, included in LAPACK. That routine computes some properties of the floating point arithmetic, such as the number of bits in the mantissa, or the epsilon number. It is very simple to do the same in Tcl and that is what I did in the machineparameters SNIT-based class available in the [Tclrep] project : http://tclrep.cvs.sourceforge.net/viewvc/tclrep/modules/machineparameters/ One motivation for such a component is to be able to test the convergence of numerical algorithms, with respect to the precision available for floating-point numbers. The following example creates a machineparameters object, computes the properties and displays it. set pp [machineparameters create %AUTO%] $pp configure -verbose 1 $pp compute $pp print $pp destroy This prints out : Machine parameters Epsilon : 1.11022302463e-16 Beta : 2 Rounding : chop Mantissa : 53 Maximum exponent : 1023 Minimum exponent : -1074 Overflow threshold : 8.98846567431e+307 Underflow threshold : 4.94065645841e-324 For example, the following is the algorithm which allows to compute epsilon, the the largest double such that 1+e>1 is not true. set factor 2. set epsilon 0.5 for {set i 0} {$i<$options(-maxiteration)} {incr i} { set epsilon [expr {$epsilon / $factor}] set inequality [expr {1.0+$epsilon>1.0}] if {$inequality==0} then { break } } The following algorithm is explained in detail in "Algorithms to Reveal Properties of Floating-Point Arithmetic", Michael A. Malcolm and in "More on Algorithms that Reveal Properties of Floating Point Arithmetic Units", W. Morven Gentleman, Scott B. Marovich. It computes the last positive integer n which can be exactly represented with a floating point number, that is, such that (n+1)-n is not equal to 1. This is because all the digits in the mantissa have been used so that the integer which is to be represented requires a digit in the exponent. set firstnoninteger 2. for {set i 0} {$i < $options(-maxiteration)} {incr i} { set firstnoninteger [expr {2.*$firstnoninteger}] set one [expr {($firstnoninteger+1.)-$firstnoninteger}] if {$one!=1.} then { break } } In addition to the Tcl implementation, more details are available in the two original articles or in the DLAMCH routine itself. ---- !!!!!! %| [Category Numerical Analysis] |% !!!!!!