logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

fpclassify - Floating point number classification of Tcl values

Description

       The  fpclassify  command  takes  a floating point number, value, and returns one of the following strings
       that describe it:

       zerovalue is a floating point zero.

       subnormalvalue is the result of a gradual underflow.

       normalvalue is an ordinary floating-point number (not zero, subnormal, infinite, nor NaN).

       infinitevalue is a floating-point infinity.

       nanvalue 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"
                  }
              }

Keywords

       floating point

Name

       fpclassify - Floating point number classification of Tcl values

See Also

expr(3tcl), mathfunc(3tcl)

Standards

       This command depends on the fpclassify() C macro conforming to “ISO C99” (i.e., to ISO/IEC 9899:1999).

Synopsis

       package require tcl9.0fpclassifyvalue
________________________________________________________________________________________________________________

See Also