Artifact a409a8505c58e284643bd14577563263b37ee4a20e48580de5a4c8018e3ee443:
- File doc/markdown/Tcl/fpclassify.md — part of check-in [b84ce0eee1] at 2026-10-04 22:10:02 on branch tip-700 — file location re-organisation (part 1) (user: Torsten, size: 1733) [annotate] [blame] [check-ins using]
- File doc/markdown/fpclassify.md — part of check-in [5e80e55e41] at 2026-09-26 22:40:07 on branch tip-700 — - added a "title" metadata element to the generated yaml block to satisfy Pandoc when converting to HTML - added markdown2html.tcl as prototype/placeholder of conversion script markdown -> HTML - added some CSS to play with a good visual representation of the generated HTML, starting with the n section pages - fixed man2markdown.tcl not giving the two .TP/.IP parsing places the same treatment (user: Torsten, size: 1733) [annotate] [blame] [check-ins using]
CommandName: fpclassify title: fpclassify ManualSection: n Version: 9.0 TclPart: Tcl TclDescription: Tcl Float Classifier Links:
- expr(n)
- mathfunc(n) Keywords:
- floating point Copyright:
- Copyright (c) 2018 Kevin B. Kenny [email protected]. All rights reserved
- Copyright (c) 2019 Donal Fellows ---
Name
fpclassify - Floating point number classification of Tcl values
Synopsis
::: {.synopsis} ::: [package]{.cmd} [require]{.sub} [tcl]{.lit} [9.0]{.lit} [fpclassify]{.cmd} [value]{.arg} :::
Description
The fpclassify command takes a floating point number, value, and returns one of the following strings that describe it:
zero : value is a floating point zero.
subnormal : value is the result of a gradual underflow.
normal : value is an ordinary floating-point number (not zero, subnormal, infinite, nor NaN).
infinite : value is a floating-point infinity.
nan : value is Not-a-Number.
The fpclassify command throws an error if value is not a floating-point value and cannot be converted to one.
Example
This shows how to check whether the result of a computation is numerically safe or not. (Note however that it does not guard against numerical errors; just against representational problems.)
set value [command-that-computes-a-value]
switch [fpclassify $value] {
normal - zero {
puts "Result is $value"
}
infinite {
puts "Result is infinite"
}
subnormal {
puts "Result is $value - WARNING! precision lost"
}
nan {
puts "Computation completely failed"
}
}
Standards
This command depends on the fpclassify() C macro conforming to "ISO C99" (i.e., to ISO/IEC 9899:1999).