class Number

Handle for a Number type. More...

Full nameKJS::Number
Definition#include <types.h>
InheritsKJS::KJSO [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

Number is a handle for a number value. KJSO::toPrimitive(), KJSO::toBoolean(), KJSO::toNumber(), KJSO::toString() and KJSO::toString() are re-implemented internally according to the specification.

Example usage:


 Number a(2), b(3.0), c; // c defaults to 0.0

 c = a.value() * b.value(); // c will be 6.0 now

 String s = c.toString(); // s holds "6"

Note the following implementation detail: Internally, the value is stored as a double and will be casted from and to other types when needed. This won't be noticable within a certain range of values but might produce unpredictable results when crossing these limits. In case this turns out to be a real problem for an application we might have to extend this class to behave more intelligently.

 Number (int i)

Number

Construct a Number type from an integer.

 Number (unsigned int u)

Number

Construct a Number type from an unsigned integer.

 Number (double d = 0.0)

Number

Construct a Number type from a double.

 Number (long int l)

Number

Construct a Number type from a long int.

 Number (long unsigned int l)

Number

Construct a Number type from a long unsigned int.

 ~Number ()

~Number

[virtual]

Destructor.

double  value ()

value

[const]

Returns: The internally stored value.

int  intValue ()

intValue

[const]

Convenience function.

Returns: The internally stored value converted to an int.

bool  isNaN ()

isNaN

[const]

Returns: True is this is not a number (NaN).

bool  isInf ()

isInf

[const]

Returns: True if Number is either +Infinity or -Infinity.


Generated by: faure on ftp.kde.com on Wed Jun 20 10:39:48 2001, using kdoc 2.0a53.