Extreme Optimization > User's Guide > Mathematics Library > General Classes > Machine Constants

Extreme Optimization User's Guide

User's Guide

Up: General Classes Next: Mathematical Constants Previous: General Classes Contents

Machine constants

The MachineConstants class contains constants related to the specific implementation of floating-point arithmetic in the .NET framework and the Common Language Runtime. The Single and Double floating-point types in the Common Language Specification (CLS) follow the IEEE-754 standard for single and double-precision floating-point numbers.

Any number representation is necessarily limited. This class provides constants that specify these limits for the CLS' floating-point types.

Many of these constants are also available in the Single and Double structures. Unfortunately, these definitions do not follow the standard conventions. For example, the name epsilon normally refers to the machine precision. It is equal to the smallest difference between numbers close to unity, roughly 10-16. The Double.Epsilon field uses the smallest positive number (roughly 10-308) instead. This makes Double.Epsilon completely useless for its intended purpose.

All machine constants are implemented as static fields of the MachineConstants class.

The following example prints the values of the constants to the console:

C# CopyCode imageCopy Code
using Extreme.Mathematics;
...
Console.WriteLine("MachineConstants.Epsilon = {0}", 
    MachineConstants.Epsilon);
Console.WriteLine("MachineConstants.SqrtEpsilon = {0}", 
    MachineConstants.SqrtEpsilon);
Console.WriteLine("MachineConstants.CubeRootEpsilon = {0}", 
    MachineConstants.CubeRootEpsilon);
Console.WriteLine("MachineConstants.MaxDouble = {0}", 
    MachineConstants.MaxDouble);
Console.WriteLine("MachineConstants.SqrtMaxDouble = {0}", 
    MachineConstants.SqrtMaxDouble);
Console.WriteLine("MachineConstants.LogMaxDouble = {0}", 
    MachineConstants.LogMaxDouble);
Console.WriteLine("MachineConstants.MinDouble = {0}", 
    MachineConstants.MinDouble);
Console.WriteLine("MachineConstants.SqrtMinDouble = {0}", 
    MachineConstants.SqrtMinDouble);
Console.WriteLine("MachineConstants.LogMinDouble = {0}", 
    MachineConstants.LogMinDouble);
Visual Basic CopyCode imageCopy Code
Imports Extreme.Mathematics
...
Console.WriteLine("MachineConstants.Epsilon = {0}", _
    MachineConstants.Epsilon)
Console.WriteLine("MachineConstants.SqrtEpsilon = {0}", _
    MachineConstants.SqrtEpsilon)
Console.WriteLine("MachineConstants.CubeRootEpsilon = {0}", _
    MachineConstants.CubeRootEpsilon)
Console.WriteLine("MachineConstants.MaxDouble = {0}", _
    MachineConstants.MaxDouble)
Console.WriteLine("MachineConstants.SqrtMaxDouble = {0}", _
    MachineConstants.SqrtMaxDouble)
Console.WriteLine("MachineConstants.LogMaxDouble = {0}", _
    MachineConstants.LogMaxDouble)
Console.WriteLine("MachineConstants.MinDouble = {0}", _
    MachineConstants.MinDouble)
Console.WriteLine("MachineConstants.SqrtMinDouble = {0}", _
    MachineConstants.SqrtMinDouble)
Console.WriteLine("MachineConstants.LogMinDouble = {0}", _
    MachineConstants.LogMinDouble)

The following table summarizes the machine constants for the Double type:

Machine precision
Epsilon Represents the machine precision for Double-precision floating point numbers.
SqrtEpsilon Represents the square root of the machine precision Epsilon for Double-precision floating point numbers.
CubeRootEpsilon Represents the cube root of the machine precision Epsilon for Double-precision floating point numbers.
Largest value
MaxDouble Represents the largest possible value of a Double-precision floating point number.
SqrtMaxDouble Represents the square root of MaxDouble.
LogMaxDouble Represents the natural logarithm of MaxDouble.
Smallest positive value
MinDouble Represents the smallest Double-precision floating point number that is greater than zero.
SqrtMinDouble Represents the square root of MinDouble.
LogMinDouble Represents the natural logarithm of MinDouble.
Table 1. Machine constants for the Double data type.

A similar set of constants is available for the Single type:

Machine precision
SingleEpsilon Represents the machine precision for Single-precision floating point numbers.
SqrtSingleEpsilon Represents the square root of the machine precision SingleEpsilon for Single-precision floating point numbers.
CubeRootSingleEpsilon Represents the cube root of the machine precision SingleEpsilon for Single-precision floating point numbers.
Largest value
MaxSingle Represents the largest possible value of a Single-precision floating point number.
SqrtMaxSingle Represents the square root of MaxSingle.
LogMaxSingle Represents the natural logarithm of MaxSingle.
Smallest positive value
MinSingle Represents the smallest Single-precision floating point number that is greater than zero.
SqrtMinSingle Represents the square root of MinSingle.
LogMinSingle Represents the natural logarithm of MinSingle.
Table 2. Machine constants for the Double data type.

Up: General Classes Next: Mathematical Constants Previous: General Classes Contents

Overview
Introduction
Features
Documentation
QuickStart Samples
Sample Applications
Downloads
Get it now!
Download trial version
How to Buy
Information
Resources
Contact Us
Search

"The Extreme Optimization Statistics Library for .NET is a major boon for those doing statistical work in .NET. I strongly recommend this product."
- Marc Brooks

"I have made it my mission to institutionalize the value of good API design.  I strongly believe that this is key to making developers more productive and happy on our platform. It is clear that you value good API design in your work, and take to heart developer productivity and synergy with the .NET framework."
- Brad Abrams,
Lead Program Manager, Microsoft.

This is a partial list of companies who are using our libraries:
ABB Robotics
Allstate
Applied Materials
Arcam
Astra Schedule
Babson College
Canadian Council on Learning
Canyon Associates
Caxton Associates
CECity
Constellation Energy
CreditSights
DeepOcean
Duke University
Dynamotive
Elecsoft
Engelhard Corporation
Epcor
Equipoise Software
Galileo International
GAM UK
Gammex
GlaxoSmithKline
Global Matrix
The Hartford
Infinera Corporation
Intel
JDS Uniphase
LaBranche & Co.
Learning & Skills Council
Jacobs Consultancy
Litman Gregory
Lucas Systems
Malvern Instruments
Medrio
Merck & Co.
Mintera.
Monitor Software
MorningStar
NanoString Technologies
Paletta Invent
Parametric Portfolio Associates
Prosanos
RATA Associates
RiskShield
Ramboll
Standard & Poor's
Strategic Analysis Corporation
Univ. of Alicante
Univ. of South Carolina
vielife
Xerox
US Army