FloatingPointNumerics Class

Summary

Helper routines for working with floating point numbers
Namespace
TCLite.Constraints
Base Types
  • object
graph BT Type-->Base0["object"] Type["FloatingPointNumerics"] class Type type-node

Syntax

public class FloatingPointNumerics

Remarks

The floating point comparison code is based on this excellent article: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

"ULP" means Unit in the Last Place and in the context of this library refers to the distance between two adjacent floating point numbers. IEEE floating point numbers can only represent a finite subset of natural numbers, with greater accuracy for smaller numbers and lower accuracy for very large numbers.

If a comparison is allowed "2 ulps" of deviation, that means the values are allowed to deviate by up to 2 adjacent floating point values, which might be as low as 0.0000001 for small numbers or as high as 10.0 for large numbers.

Methods

Name Value Summary
AreAlmostEqualUlps(double, double, long) bool
Compares two double precision floating point values for equality
static
AreAlmostEqualUlps(float, float, int) bool
Compares two floating point values for equality
static
ReinterpretAsDouble(long) double
Reinterprets the memory contents of an integer value as a double precision floating point value
static
ReinterpretAsFloat(int) float
Reinterprets the memory contents of an integer as a floating point value
static
ReinterpretAsInt(float) int
Reinterprets the memory contents of a floating point value as an integer value
static
ReinterpretAsLong(double) long
Reinterprets the memory contents of a double precision floating point value as an integer value
static