Class DoubleBits
DoubleBits manipulates Double numbers
by using bit manipulation and bit-field extraction.
For some operations (such as determining the exponent)
this is more accurate than using mathematical operations
(which suffer from round-off error).
The algorithms and constants in this class
apply only to IEEE-754 double-precision floating point format.
Assembly: NetTopologySuite.dll
Syntax
Constructors
|
Edit this page
View Source
DoubleBits(double)
Declaration
public DoubleBits(double x)
Parameters
Type |
Name |
Description |
double |
x |
|
Fields
|
Edit this page
View Source
ExponentBias
Declaration
public const int ExponentBias = 1023
Field Value
Properties
|
Edit this page
View Source
BiasedExponent
Determines the exponent for the number.
Declaration
public int BiasedExponent { get; }
Property Value
|
Edit this page
View Source
Double
Declaration
public double Double { get; }
Property Value
|
Edit this page
View Source
Exponent
Determines the exponent for the number.
Declaration
public int Exponent { get; }
Property Value
Methods
|
Edit this page
View Source
GetBit(int)
Declaration
Parameters
Type |
Name |
Description |
int |
i |
|
Returns
|
Edit this page
View Source
GetExponent(double)
Declaration
public static int GetExponent(double d)
Parameters
Type |
Name |
Description |
double |
d |
|
Returns
|
Edit this page
View Source
MaximumCommonMantissa(double, double)
Declaration
public static double MaximumCommonMantissa(double d1, double d2)
Parameters
Returns
|
Edit this page
View Source
NumCommonMantissaBits(DoubleBits)
This computes the number of common most-significant bits in the mantissa.
It does not count the hidden bit, which is always 1.
It does not determine whether the numbers have the same exponent - if they do
not, the value computed by this function is meaningless.
Declaration
public int NumCommonMantissaBits(DoubleBits db)
Parameters
Returns
Type |
Description |
int |
The number of common most-significant mantissa bits.
|
|
Edit this page
View Source
PowerOf2(int)
Declaration
public static double PowerOf2(int exp)
Parameters
Type |
Name |
Description |
int |
exp |
|
Returns
|
Edit this page
View Source
ToBinaryString(double)
Declaration
public static string ToBinaryString(double d)
Parameters
Type |
Name |
Description |
double |
d |
|
Returns
|
Edit this page
View Source
ToString()
A representation of the Double bits formatted for easy readability.
Declaration
public override string ToString()
Returns
Overrides
|
Edit this page
View Source
TruncateToPowerOfTwo(double)
Declaration
public static double TruncateToPowerOfTwo(double d)
Parameters
Type |
Name |
Description |
double |
d |
|
Returns
|
Edit this page
View Source
ZeroLowerBits(int)
Declaration
public void ZeroLowerBits(int nBits)
Parameters
Type |
Name |
Description |
int |
nBits |
|