math::machineparameters(3tcl)
β¨ math::machineparameters β¨
okay bestie, welcome to math::machineparameters, a little slice of the tclrep corner of the world. π It's a Tcl manual page, it's about floating point, and yes it's giving extremely niche but also extremely iconic. Let's go. π¦
πΈ NAME πΈ
math::machineparameters β computes double precision machine parameters. that's it, that's the whole job, and it does it flawlessly. π
β¨ SYNOPSIS β¨
package require Tcl 8.5 9
package require snit
package require math::machineparameters 0.2
machineparameters create objectname ?options...?
objectname configure ?options...?
objectname cget opt
objectname destroy
objectname compute
objectname get key
objectname tostring
objectname print
π DESCRIPTION π
So. The math::machineparameters package is literally the Tcl equivalent of the DLAMCH LAPACK function. no cap. π«Ά
In floating point systems, a floating point number is represented by
x = +/- d1 d2 ... dt basis^e
where the digits satisfy
0 <= di <= basis - 1, i = 1, t
with the convention that:
tis the size of the mantissabasisis the basis (aka the "radix")
The compute method computes all machine parameters. Then the get method is right there whenever you need to grab each parameter one by one. And the print method prints a whole report on standard output, for when you want the receipts. π
π EXAMPLE π
In the following example, one computes the parameters of a desktop under Linux with the following Tcl 8.4.19 properties:
% parray tcl_platform
tcl_platform(byteOrder) = littleEndian
tcl_platform(machine) = i686
tcl_platform(os) = Linux
tcl_platform(osVersion) = 2.6.24-19-generic
tcl_platform(platform) = unix
tcl_platform(tip,268) = 1
tcl_platform(tip,280) = 1
tcl_platform(user) = <username>
tcl_platform(wordSize) = 4
The following example creates a machineparameters object, computes the properties and displays it.
set pp [machineparameters create %AUTO%]
$pp compute
$pp print
$pp destroy
This prints out:
Machine parameters
Epsilon : 1.11022302463e-16
Beta : 2
Rounding : proper
Mantissa : 53
Maximum exponent : 1024
Minimum exponent : -1021
Overflow threshold : 8.98846567431e+307
Underflow threshold : 2.22507385851e-308
That compares well with the results produced by Lapack 3.1.1:
Epsilon = 1.11022302462515654E-016
Safe minimum = 2.22507385850720138E-308
Base = 2.0000000000000000
Precision = 2.22044604925031308E-016
Number of digits in mantissa = 53.000000000000000
Rounding mode = 1.00000000000000000
Minimum exponent = -1021.0000000000000
Underflow threshold = 2.22507385850720138E-308
Largest exponent = 1024.0000000000000
Overflow threshold = 1.79769313486231571E+308
Reciprocal of safe minimum = 4.49423283715578977E+307
The following example creates a machineparameters object, computes the properties and gets the epsilon for the machine.
set pp [machineparameters create %AUTO%]
$pp compute
set eps [$pp get -epsilon]
$pp destroy
π¦ REFERENCES π¦
- "Algorithms to Reveal Properties of Floating-Point Arithmetic", Michael A. Malcolm, Stanford University, Communications of the ACM, Volume 15 , Issue 11 (November 1972), Pages: 949 - 951
- "More on Algorithms that Reveal Properties of Floating, Point Arithmetic Units", W. Morven Gentleman, University of Waterloo, Scott B. Marovich, Purdue University, Communications of the ACM, Volume 17 , Issue 5 (May 1974), Pages: 276 - 277
π CLASS API π
machineparameters create objectname ?options...?β This command creates a newmachineparametersobject and returns the fully qualified name of the object command as its result. your new child, basically. πΌ-verbose verboseβ Set this option to1to enable verbose logging. This option is mainly for debug purposes. The default value ofverboseis0.
π OBJECT API π
objectname configure ?options...?β This command configures the options of the objectobjectname. The options are the same as the static methodcreate. same energy, different door. πͺobjectname cget optβ Returns the value of the option whose name isopt. The options are the same as the methodcreateandconfigure.objectname destroyβ Destroys the objectobjectname. rip bestie πobjectname computeβ Computes the machine parameters. the main character moment. β¨objectname get keyβ Returns the value corresponding with the givenkey. The following is the list of available keys:-epsilon: smallest value so that1+epsilon>1is false-rounding: The rounding mode used on the machine. The rounding occurs when more thantdigits would be required to represent the number. Two modes can be determined with the current system : "chop" means than onlytdigits are kept, no matter the value of the number; "proper" means that another rounding mode is used, be it "round to nearest", "round up", "round down".-basis: the basis of the floating-point representation. The basis is usually 2, i.e. binary representation (for example IEEE 754 machines), but some machines (like HP calculators for example) uses 10, or 16, etc...-mantissa: the number of bits in the mantissa-exponentmax: the largest positive exponent before overflow occurs-exponentmin: the largest negative exponent before (gradual) underflow occurs-vmax: largest positive value before overflow occurs-vmin: largest negative value before (gradual) underflow occurs
objectname tostringβ Return a report for machine parameters.objectname printβ Print machine parameters on standard output.
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
π COPYRIGHT π
Copyright (c) 2008 Michael Baudin <michael.baudin@sourceforge.net>
and that's the whole page, bestie!! π«Ά this one came straight out of tcllib, version0.2, and it lives its life asmath::machineparameters(3tcl). go forth and compute those machine parameters, you absolute icon. πβ¨π
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- Copyright (c) 2008 Michael Baudin <michael\&.baudin@sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms