solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
Loading...
Searching...
No Matches
Classes | Enumerations
cmp.h File Reference

Floating-point comparison library for precise and robust comparisons. More...

#include <float.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
Include dependency graph for cmp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cmp_config_t
 Default configuration for each floating-point type. More...
 

Enumerations

enum  cmp_mode_t { CMP_ABSOLUTE , CMP_RELATIVE , CMP_ULPS , CMP_COMBINED }
 Comparison modes for floating-point numbers. More...
 

Detailed Description

Floating-point comparison library for precise and robust comparisons.

This library provides functions and macros for comparing floating-point numbers using different modes: relative epsilon, absolute epsilon, ULPS, and combined.

Comparison Mode Recommendations:

Typical Epsilon Values:

Author
[Your Name]
Date
September 2025

Definition in file cmp.h.

Enumeration Type Documentation

◆ cmp_mode_t

enum cmp_mode_t

Comparison modes for floating-point numbers.

Enumerator
CMP_ABSOLUTE 

Absolute epsilon: |a - b| ≤ ε. Best for fixed-scale data.

CMP_RELATIVE 

Relative epsilon: |a - b| ≤ ε × max(|a|, |b|). Best for scientific computing.

CMP_ULPS 

Units in Last Place: bit-wise difference ≤ N ULPS. Best for bit-exact comparisons.

CMP_COMBINED 

Combined: |a - b| ≤ ε OR |a - b| ≤ ε × max(|a|, |b|). Most robust.

Definition at line 50 of file cmp.h.