fpclassify - Linux


The fpclassify command determines the class of a floating-point number, providing insights into its nature and characteristics. It’s particularly useful for identifying special floating-point values such as NaN, infinity, and subnormal numbers.


fpclassify [-h] [-v] <floating-point-number>


  • -h, –help: Display help information and exit.
  • -v, –version: Display version information and exit.


Simple Usage:

$ fpclassify 0.0

Identifying NaN:

$ fpclassify nan(0)

Checking Infinity:

$ fpclassify inf

Detecting Subnormal Numbers:

$ fpclassify 1e-308

Common Issues

Incorrect Number Format:

If the provided input is not a valid floating-point number, fpclassify will return FP_INVALID. Ensure that the number is formatted correctly with a decimal point or exponent.

Special Floating-Point Values:

Be aware that NaN and infinity are represented differently based on the floating-point standard (FP_NAN and FP_INFINITE). Double-check the expected values according to the context.


fpclassify can be combined with other tools for advanced tasks, such as:

  • grep: Filter output based on specific floating-point classes.
  • awk: Extract and analyze floating-point numbers from large datasets.
  • python: Create scripts to automate floating-point classification tasks.

Related Commands

  • isnan: Checks if a value is NaN.
  • isinf: Checks if a value is infinity.