Unicorn XML Toolkit
Version 1.00.00

Namespace EcmaScript
Class CNumber

class CNumber {
public:
    CNumber();
    CNumber(int nValue);
    CNumber(double dblValue);
    ~CNumber();
public:
    bool IsInt32();
    double GetDouble();
    long GetInt32();
    unsigned long GetUint32();
    unsigned short GetUint16();
    CNumber operator=(CNumber numValue);
    CNumber operator-();
    CNumber operator~();
    friend CNumber operator*(CNumber numValue1, CNumber numValue2);
    friend CNumber operator/(CNumber numValue1, CNumber numValue2);
    friend CNumber operator%(CNumber numValue1, CNumber numValue2);
    friend CNumber operator+(CNumber numValue1, CNumber numValue2);
    friend CNumber operator-(CNumber numValue1, CNumber numValue2);
    friend CNumber operator<<(CNumber numValue1, CNumber numValue2);
    friend CNumber operator>>(CNumber numValue1, CNumber numValue2);
    CNumber UnsignedRightShift(CNumber numValue);
    friend bool operator<(CNumber numValue1, CNumber numValue2);
    friend bool operator>(CNumber numValue1, CNumber numValue2);
    friend bool operator<=(CNumber numValue1, CNumber numValue2);
    friend bool operator>=(CNumber numValue1, CNumber numValue2);
    friend bool operator==(CNumber numValue1, CNumber numValue2);
    friend bool operator!=(CNumber numValue1, CNumber numValue2);
    friend CNumber operator&(CNumber numValue1, CNumber numValue2);
    friend CNumber operator|(CNumber numValue1, CNumber numValue2);
    friend CNumber operator^(CNumber numValue1, CNumber numValue2);
    bool IsNaN();
    bool IsPositiveZero();
    bool IsNegativeZero();
    bool IsPositiveInfinity();
    bool IsNegativeInfinity();
    static CNumber MaxValue();
    static CNumber MinValue();
    static CNumber NaN();
    static CNumber NegativeZero();
    static CNumber NegativeInfinity();
    static CNumber PositiveInfinity();
    CString ToString();
    CNumber ToInteger();
    CNumber ToInt32();
    CNumber ToUInt32();
    CNumber ToUInt16();
    static bool ParseString(
        const CString &strValue, CNumber &numResult);
    static bool ParseLiteral(
        const CString &strValue, CNumber &numResult);
    static bool ParseInteger(
        const CString &strValue, int nRadix, CNumber &numResult);
    static bool ParseDecimal(
        const CString &strValue, CNumber &numResult, bool bSign);
    };

The ECMAScript number.

Since:
1.00.00
Version:
1.00.00
Author:
Alexey Gokhberg
Constructor/Destructor Summary
CNumber ();
����������Constructs the number.
CNumber (int nValue);
����������Constructs the number with the specified integer value.
CNumber (double dblValue);
����������Constructs the number with the specified real value.
~CNumber ();
����������Destroys the number.

Function Summary
bool IsInt32 ();
����������Tests whether this number is a 32-bit integer.
double GetDouble ();
����������Returns the real value represented by this number.
long GetInt32 ();
����������Converts this number to a 32-bit integer.
unsigned�long GetUint32 ();
����������Converts this number to an unsigned 32-bit integer.
unsigned�short GetUint16 ();
����������Converts this number to an unsigned 16-bit integer.
CNumber operator= (CNumber numValue);
����������Assigns the new value to this number.
CNumber operator- ();
����������Performs the unary minus operation.
CNumber operator~ ();
����������Performs the bitwise NOT operation.
CNumber operator* (CNumber numValue1, CNumber numValue2);
����������Performs the multiplication operation.
CNumber operator/ (CNumber numValue1, CNumber numValue2);
����������Performs the division operation.
CNumber operator% (CNumber numValue1, CNumber numValue2);
����������Performs the ECMAScript remainder operation.
CNumber operator+ (CNumber numValue1, CNumber numValue2);
����������Performs the addition operation.
CNumber operator- (CNumber numValue1, CNumber numValue2);
����������Performs the subtraction operation.
CNumber operator<< (CNumber numValue1, CNumber numValue2);
����������Performs the left shift operation.
CNumber operator>> (CNumber numValue1, CNumber numValue2);
����������Performs the right shift operation.
CNumber UnsignedRightShift (CNumber numValue);
����������Performs the unsigned right shift operation.
bool operator< (CNumber numValue1, CNumber numValue2);
����������Performs the less-than comparison operation.
bool operator> (CNumber numValue1, CNumber numValue2);
����������Performs the greater-than comparison operation.
bool operator<= (CNumber numValue1, CNumber numValue2);
����������Performs the less-than-or-equal comparison operation.
bool operator>= (CNumber numValue1, CNumber numValue2);
����������Performs the greater-than-or-equal comparison operation.
bool operator== (CNumber numValue1, CNumber numValue2);
����������Performs the equals comparison operation.
bool operator!= (CNumber numValue1, CNumber numValue2);
����������Performs the does-not-equal comparison operation.
CNumber operator& (CNumber numValue1, CNumber numValue2);
����������Performs the bitwise AND operation.
CNumber operator| (CNumber numValue1, CNumber numValue2);
����������Performs the bitwise OR operation.
CNumber operator^ (CNumber numValue1, CNumber numValue2);
����������Performs the bitwise XOR operation.
bool IsNaN ();
����������Tests whether this number represents NaN.
bool IsPositiveZero ();
����������Tests whether this number represents a positive zero.
bool IsNegativeZero ();
����������Tests whether this number represents a negative zero.
bool IsPositiveInfinity ();
����������Tests whether this number represents a positive infinity.
bool IsNegativeInfinity ();
����������Tests whether this number represents a negative infinity.
CNumber MaxValue ();
����������Returns the maximum finite number.
CNumber MinValue ();
����������Returns the minimum finite number.
CNumber NaN ();
����������Returns the number representing NaN.
CNumber NegativeZero ();
����������Returns the number representing a negative zero.
CNumber NegativeInfinity ();
����������Returns the number representing a negative infinity.
CNumber PositiveInfinity ();
����������Returns the number representing a positive infinity.
CString ToString ();
����������Converts this number to a string.
CNumber ToInteger ();
����������Converts this number to an integer.
CNumber ToInt32 ();
����������Converts this number to a 32-bit integer.
CNumber ToUInt32 ();
����������Converts this number to a 32-bit unsigned integer.
CNumber ToUInt16 ();
����������Converts this number to a 16-bit unsigned integer.
bool ParseString (const CString &strValue, CNumber &numResult);
����������Parses the string representation of number conforming to the StrDecimalLiteral syntax defined by ECMAScript.
bool ParseLiteral (const CString &strValue, CNumber &numResult);
����������Parses the string representation of number conforming to the DecimalLiteral syntax defined by ECMAScript.
bool ParseInteger (const CString &strValue, int nRadix, CNumber &numResult);
����������Parses the string representation of number conforming to the syntax required for the parseInt function defined by ECMAScript.
bool ParseDecimal (const CString &strValue, CNumber &numResult, bool bSign);
����������Parses the string representation of a decimal value.

Constructor/Destructor Detail

CNumber

CNumber();

Constructs the number.

This number is assigned the value 0 .

CNumber

CNumber(int nValue);

Constructs the number with the specified integer value.

Parameters:
nValue - the integer value of this number

CNumber

CNumber(double dblValue);

Constructs the number with the specified real value.

Parameters:
dblValue - the real value of this number

~CNumber

~CNumber();

Destroys the number.

Function Detail

IsInt32

bool IsInt32();

Tests whether this number is a 32-bit integer.

Returns:
true if this number is a 32-bit integer; false otherwise

GetDouble

double GetDouble();

Returns the real value represented by this number.

Returns:
the real value represented by this number

GetInt32

long GetInt32();

Converts this number to a 32-bit integer.

Returns:
the result of conversion

GetUint32

unsigned long GetUint32();

Converts this number to an unsigned 32-bit integer.

Returns:
the result of conversion

GetUint16

unsigned short GetUint16();

Converts this number to an unsigned 16-bit integer.

Returns:
the result of conversion

operator=

CNumber operator=(CNumber numValue);

Assigns the new value to this number.

Parameters:
numValue - the value to assign
Returns:
this number

operator-

CNumber operator-();

Performs the unary minus operation.

This number remains unchanged.

Returns:
the result of the operation

operator~

CNumber operator~();

Performs the bitwise NOT operation.

This number remains unchanged.

Returns:
the result of the operation

operator*

friend CNumber operator*(CNumber numValue1, CNumber numValue2);

Performs the multiplication operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator/

friend CNumber operator/(CNumber numValue1, CNumber numValue2);

Performs the division operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator%

friend CNumber operator%(CNumber numValue1, CNumber numValue2);

Performs the ECMAScript remainder operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator+

friend CNumber operator+(CNumber numValue1, CNumber numValue2);

Performs the addition operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator-

friend CNumber operator-(CNumber numValue1, CNumber numValue2);

Performs the subtraction operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator<<

friend CNumber operator<<(CNumber numValue1, CNumber numValue2);

Performs the left shift operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator>>

friend CNumber operator>>(CNumber numValue1, CNumber numValue2);

Performs the right shift operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

UnsignedRightShift

CNumber UnsignedRightShift(CNumber numValue);

Performs the unsigned right shift operation.

This number serves as the left-hand operand and remains unchanged.

Parameters:
numValue - the right-hand operand
Returns:
the result of the operation

operator<

friend bool operator<(CNumber numValue1, CNumber numValue2);

Performs the less-than comparison operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator>

friend bool operator>(CNumber numValue1, CNumber numValue2);

Performs the greater-than comparison operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator<=

friend bool operator<=(CNumber numValue1, CNumber numValue2);

Performs the less-than-or-equal comparison operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator>=

friend bool operator>=(CNumber numValue1, CNumber numValue2);

Performs the greater-than-or-equal comparison operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator==

friend bool operator==(CNumber numValue1, CNumber numValue2);

Performs the equals comparison operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator!=

friend bool operator!=(CNumber numValue1, CNumber numValue2);

Performs the does-not-equal comparison operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator&

friend CNumber operator&(CNumber numValue1, CNumber numValue2);

Performs the bitwise AND operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator|

friend CNumber operator|(CNumber numValue1, CNumber numValue2);

Performs the bitwise OR operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

operator^

friend CNumber operator^(CNumber numValue1, CNumber numValue2);

Performs the bitwise XOR operation.

Parameters:
numValue1 - the left-hand operand
numValue2 - the right-hand operand
Returns:
the result of the operation

IsNaN

bool IsNaN();

Tests whether this number represents NaN.

Returns:
true if this number represents NaN; false otherwise

IsPositiveZero

bool IsPositiveZero();

Tests whether this number represents a positive zero.

Returns:
true if this number represents a positive zero; false otherwise

IsNegativeZero

bool IsNegativeZero();

Tests whether this number represents a negative zero.

Returns:
true if this number represents a negative zero; false otherwise

IsPositiveInfinity

bool IsPositiveInfinity();

Tests whether this number represents a positive infinity.

Returns:
true if this number represents a positive infinity; false otherwise

IsNegativeInfinity

bool IsNegativeInfinity();

Tests whether this number represents a negative infinity.

Returns:
true if this number represents a negative infinity; false otherwise

MaxValue

static CNumber MaxValue();

Returns the maximum finite number.

Returns:
the maximum finite number

MinValue

static CNumber MinValue();

Returns the minimum finite number.

Returns:
the minimum finite number

NaN

static CNumber NaN();

Returns the number representing NaN.

Returns:
the number representing NaN

NegativeZero

static CNumber NegativeZero();

Returns the number representing a negative zero.

Returns:
the number representing a negative zero

NegativeInfinity

static CNumber NegativeInfinity();

Returns the number representing a negative infinity.

Returns:
the number representing a negative infinity

PositiveInfinity

static CNumber PositiveInfinity();

Returns the number representing a positive infinity.

Returns:
the number representing a positive infinity

ToString

CString ToString();

Converts this number to a string.

The result of conversion is returned; this number remains unchanged.

Returns:
the result of conversion

ToInteger

CNumber ToInteger();

Converts this number to an integer.

This number remains unchanged.

Returns:
the number containing the result of conversion

ToInt32

CNumber ToInt32();

Converts this number to a 32-bit integer.

This number remains unchanged.

Returns:
the number containing the result of conversion

ToUInt32

CNumber ToUInt32();

Converts this number to a 32-bit unsigned integer.

This number remains unchanged.

Returns:
the number containing the result of conversion

ToUInt16

CNumber ToUInt16();

Converts this number to a 16-bit unsigned integer.

This number remains unchanged.

Returns:
the number containing the result of conversion

ParseString

static bool ParseString(
    const CString &strValue, CNumber &numResult);

Parses the string representation of number conforming to the StrDecimalLiteral syntax defined by ECMAScript.

Parameters:
strValue - the string to parse
numResult - on return, the result number if parsing succeeded; unspecified otherwise
Returns:
true if parsing succeeded; false otherwise

ParseLiteral

static bool ParseLiteral(
    const CString &strValue, CNumber &numResult);

Parses the string representation of number conforming to the DecimalLiteral syntax defined by ECMAScript.

Parameters:
strValue - the string to parse
numResult - on return, the result number if parsing succeeded; unspecified otherwise
Returns:
true if parsing succeeded; false otherwise

ParseInteger

static bool ParseInteger(
    const CString &strValue, int nRadix, CNumber &numResult);

Parses the string representation of number conforming to the syntax required for the parseInt function defined by ECMAScript.

Parameters:
strValue - the string to parse
nRadix - the radix value between 2 and 36
numResult - on return, the result number if parsing succeeded; unspecified otherwise
Returns:
true if parsing succeeded; false otherwise

ParseDecimal

static bool ParseDecimal(
    const CString &strValue, CNumber &numResult, bool bSign);

Parses the string representation of a decimal value.

This is a miscellaneous function used by ParseString and ParseLiteral .

Parameters:
strValue - the string to parse
numResult - on return, the result number if parsing succeeded; unspecified otherwise
bSign - indicates whether the plus or minus sign is allowed in the source string
Returns:
true if parsing succeeded; false otherwise

Unicorn XML Toolkit
Version 1.00.00


This document was created using Unicorn DOC++.

Copyright 1999-2001 Unicorn Enterprises SA.
All Rights Reserved.