C isnormal() Macro

Beginner
5 min read
Updated: Nov 2026
3 examples
math.h

Definition

In C, isnormal() is a <math.h> classification macro. It tells you if a floating value is a normal number. True is non-zero; false is 0.

A normal number is a regular finite value that is not zero, not a tiny subnormal, not infinity, and not NaN. Most everyday measurements you store in double are normal.

Pass one real floating argument. Include <math.h>. Print the result as 0 or 1. Combine it with isnan, isinf, and isfinite when you classify results.

Syntax

Ask whether a value is a normal number. Start with this call.

C
isnormal(x);
CallWhat it does
isnormal(3.5)Returns non-zero because 3.5 is a normal finite number.
isnormal(0.0)Returns 0 because zero is not classified as normal.
isnormal(NAN)Returns 0 because NaN is not a normal number.

Include <math.h>. On GCC, link with -lm. Zero, subnormals, infinities, and NaNs all fail this test.

Library declarations
C
#define isnormal(x) /* implementation-defined macro */

Parameters

ParameterDescription
xRequired. The floating value to classify (float, double, or long double).

Return Value

Return ValueDescription
Non-zero (true)When x is a normal floating number.
0 (false)When x is zero, subnormal, infinity, or NaN.

C Examples

Example 1 — Basic Normal Check

Print 1 for normal numbers and 0 for special cases.

C
#include <stdio.h>
#include <math.h>

int main(void) {
    printf("%d\n", (int)isnormal(3.5));
    printf("%d\n", (int)isnormal(0.0));
    printf("%d\n", (int)isnormal(INFINITY));
    printf("%d\n", (int)isnormal(NAN));
    return 0;
}

How It Works

  1. Include math.h. That provides the classification macros.
  2. Normal value. 3.5 prints 1.
  3. Zero fails. Zero is finite but not normal, so print 0.
  4. Special values fail. Infinity and NaN also print 0.

Example 2 — Accept Only Normal Inputs

Reject zero and special values before a calculation that needs a solid magnitude.

C
#include <stdio.h>
#include <math.h>

int main(void) {
    double x = 2.5;

    if (isnormal(x)) {
        printf("ready\n");
    } else {
        printf("skip\n");
    }

    return 0;
}

How It Works

  1. Pick a sample. x is 2.5.
  2. Ask isnormal. The macro returns true.
  3. Continue the work. Print ready.
  4. Why filter. Normal values are the everyday finite numbers your formula expects.

Example 3 — Contrast with isfinite

Zero is finite, but isnormal still returns 0.

C
#include <stdio.h>
#include <math.h>

int main(void) {
    double z = 0.0;

    printf("isfinite=%d\n", (int)isfinite(z));
    printf("isnormal=%d\n", (int)isnormal(z));
    return 0;
}

How It Works

  1. Use zero. Zero is a valid floating value.
  2. Check isfinite. Zero is finite, so that line prints 1.
  3. Check isnormal. Zero is not normal, so that line prints 0.
  4. Choose carefully. Pick the macro that matches your rule.

Frequently Asked Questions

isnormal() returns non-zero when its argument is a normal floating number, otherwise 0.
x is required. It is the floating value you want to classify.
A non-zero value for normal numbers, or 0 for zero, subnormals, infinities, and NaNs.
Include <math.h>. On GCC, link with -lm.
isfinite() is true for zeros and many tiny values. isnormal() is true only for normal finite numbers.

Next: isunordered()

Test whether two floating values cannot be ordered.

isunordered() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful