Cross-Platform C++

ot
class NumUtils

#include "ot/base/NumUtils.h"

Class module containing functions to convert numbers into Strings and vice versa.

See also:
StringUtils



Method Summary
static double ToDouble(const String& str)
         Converts a String into a double-precision floating-point value.
static int ToInt(const String& str, int base)
         Converts a String into an integer value.
static long ToLong(const String& str, int base)
         Converts a String into a long integer value.
static String ToString(long x)
         Converts the long value x into a String.
static String ToString(unsigned long x)
         Converts the unsigned long value x into a String.
static String ToString(int x)
         Converts the integer value x into a String.
static String ToString(unsigned int x)
         Converts the unsigned integer value x into a String.
static String ToString(double d)
         Converts the double-precision floating-point value x into a String.

Method Detail

ToDouble

static double ToDouble(const String& str)
Converts a String into a double-precision floating-point value.

Parameters:
str - the String to convert
Returns:
the String converted into an double. 0.0 is returned if the String cannot be converted.

ToInt

static int ToInt(const String& str,
                 int base)
Converts a String into an integer value.

Parameters:
str - the String to convert
base - the number base to use for the conversion (e.g. 10 for decimal, 16 for hexadecimal)
Returns:
the String converted into an integer. 0 is returned if the String cannot be converted.

ToLong

static long ToLong(const String& str,
                   int base)
Converts a String into a long integer value.

Parameters:
str - the String to convert
base - the number base to use for the conversion (e.g. 10 for decimal, 16 for hexadecimal)
Returns:
the String converted into a long integer. 0 is returned if the String cannot be converted.

ToString

static String ToString(long x)
Converts the long value x into a String.


ToString

static String ToString(unsigned long x)
Converts the unsigned long value x into a String.


ToString

static String ToString(int x)
Converts the integer value x into a String.


ToString

static String ToString(unsigned int x)
Converts the unsigned integer value x into a String.


ToString

static String ToString(double d)
Converts the double-precision floating-point value x into a String.



Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements