Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Double Class Reference

Inheritance diagram for Double:

Styled List of all members.

Public Types

typedef double tValue

Private Types

enum  Flags {
  Fill = 1, Left = Fill << 1, Prec = Left << 1, Hash = Prec << 1,
  Space = Hash << 1, Zero = Space << 1, Sign = Zero << 1, Comma = Sign << 1,
  Plus = Comma << 1, Array = Plus << 1
}

Static Private Member Functions

static tValue pow10 (uint exp)
static tValue parse (char[] src, uint *ate=null)
static int format (double i, inout Style style)
static char[] format (char[] dst, tValue x, uint decimals=6, bool scientific=false)
static void error (char[] msg)

Detailed Description

A set of functions for converting between string and floating- point values.

While these functions are all static, they are encapsulated within a class inheritance to preserve some namespace cohesion. One might use structs for encapsualtion instead, but then inheritance would be lost. Note that the root class, Styled, is abstract to prevent accidental instantiation of these classes.

Definition at line 67 of file Double.d.


Member Typedef Documentation

typedef double tValue
 

Definition at line 69 of file Double.d.


Member Enumeration Documentation

enum Flags [inherited]
 

Declare stylistic flags

Enumeration values:
Fill 
Left 
Prec 
Hash 
Space 
Zero 
Sign 
Comma 
Plus 
Array 

Definition at line 76 of file Styled.d.


Member Function Documentation

static tValue pow10 uint  exp  )  [inline, static, private]
 

Internal function to convert an exponent specifier to a floating point value.

Definition at line 78 of file Double.d.

References assert().

Referenced by parse().

static tValue parse char[]  src,
uint *  ate = null
[inline, static, private]
 

Convert a formatted string of digits to a floating- point number. Good for general use, but use David Gay's dtoa package if serious rounding adjustments should be applied.

Definition at line 115 of file Double.d.

References memicmp(), and pow10().

static int format double  i,
inout Style  style
[inline, static, private]
 

Convert float to string based upon Style bits.

Definition at line 192 of file Double.d.

References format().

Referenced by format().

static char [] format char[]  dst,
tValue  x,
uint  decimals = 6,
bool  scientific = false
[inline, static, private]
 

Convert a float to a string. This produces pretty good results for the most part, though one should use David Gay's dtoa package for best accuracy.

Note that the approach first normalizes a base10 mantissa, then pulls digits from the left side whilst emitting them (rightward) to the output.

Definition at line 212 of file Double.d.

References assert().

static void error char[]  msg  )  [inline, static, inherited]
 

Throw an exception with the provided messsage

Definition at line 338 of file Styled.d.

Referenced by Number::format(), Format::print(), and Format::Sprintf::utf8().


The documentation for this class was generated from the following file:
Generated on Mon Nov 14 10:59:51 2005 for Mango by  doxygen 1.4.0