fpclassify(3tcl)
π fpclassify β the Tcl Float Classifier (manual page fpclassify(3tcl), bestie) π
okay so listen. this is fpclassify from the 3tcl manual, section 3tcl, and it is genuinely one of those little commands that saves your whole entire life when your math goes feral. let's get into it. π¦
β¨ NAME β¨
fpclassify β Floating point number classification of Tcl values
like, it looks at a float and tells you what kind of float it is. vibe check for numbers. π
β¨ SYNOPSIS β¨
package require tcl 9.0
fpclassify value
so first you gotta pull in Tcl 9.0 (yes girl, 9.0, no cap), and then you just hand fpclassify a value and let it cook. π
β¨ DESCRIPTION β¨
The fpclassify command takes a floating point number, value, and hands you back one of these strings describing it. literally one of these, that's the whole menu:
zeroβ value is a floating point zero. a whole zero. nothing happening.subnormal</subnormal> β value is the result of a gradual underflow. π«normalβ value is an ordinary floating-point number (not zero, not subnormal, not infinite, and not NaN either β just a normal girl doing normal girl math).infiniteβ value is a floating-point infinity. it goes on forever fr fr.nanβ value is Not-a-Number. π
and bestie, hear me: the fpclassify command throws an error if value is not a floating-point value and cannot be converted to one. it will not hold your hand, it will not pretend. error. periodt.
β¨ EXAMPLE β¨
this is how you check whether the result of a computation is numerically safe or not. π
heads up tho β it does not guard against numerical errors; it just guards against representational problems. iykyk. π
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"
}
}
see how cute that switch is? normal - zero sharing one branch, iconic. and then subnormal hits you with the WARNING! precision lost like a text from your ex. and nan is just "Computation completely failed" which is honestly so blunt and so real. π
β¨ SEE ALSO β¨
go read those next, they're the group chat π
β¨ KEYWORDS β¨
floating point
β¨ STANDARDS β¨
This command depends on the fpclassify() C macro conforming to βISO C99β (i.e., to ISO/IEC 9899:1999). so like... it's standards girlie certified. π
β¨ COPYRIGHT β¨
Copyright Β© 2018 Kevin B. Kenny <kennykb@acm.org>. All rights reserved
and that's the whole page, bestie!! πΈ this was fpclassify(3tcl) from the Tcl docs, version 9.0, and yes mamas we read it all the way to the bottom, ate and left no crumbs πβ¨π
π¦ where this page comes from
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 2018 Kevin B. Kenny <kennykb@acm.org>. All rights reserved
- Copyright (c) 2019 Donal Fellows
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms