fpclassify(n) Tcl Float Classifier fpclassify(n)

```

```

# [NAME](#NAME)

fpclassify - Floating point number classification of Tcl values

# [SYNOPSIS](#SYNOPSIS)

**package require tcl 9.0**

**fpclassify value**

```

```

# [DESCRIPTION](#DESCRIPTION)

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

[**zero**](#zero)

*value* is a floating point zero.

[**subnormal**](#subnormal)

*value* is the result of a gradual underflow.

[**normal**](#normal)

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

[**infinite**](#infinite)

*value* is a floating-point infinity.

[**nan**](#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](#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"


    }
}
```

# [SEE ALSO](#SEE_ALSO)

[expr(n)](/man/os/tcl/expr.n), [mathfunc(n)](/man/os/tcl/mathfunc.n)

# [KEYWORDS](#KEYWORDS)

floating point

# [STANDARDS](#STANDARDS)

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

# [COPYRIGHT](#COPYRIGHT)

```
Copyright © 2018 Kevin B. Kenny <kennykb@acm.org>. All rights reserved
```

9.0 Tcl

---

Document: fpclassify(n) from tcl 9.1.0-r1 (Chainguard OS)
Source: https://downloads.sourceforge.net/project/tcl/Tcl/9.1.0/tcl9.1.0-src.tar.gz
