DCL 3.7.4
Loading...
Searching...
No Matches
Double Class Reference

#include <Numeric.h>

Public Member Functions

 Double (double _d)
String toString () const

Static Public Member Functions

static String toString (double _d, const wchar_t *_format)
static double parse (const wchar_t *_number) __DCL_THROWS1(NumericConvertException *)
static double parse (const wchar_t *_number, double _default)
static ByteString toByteString (double _f, const char *_format)

Public Attributes

double __d

Detailed Description

Definition at line 191 of file Numeric.h.

Constructor & Destructor Documentation

◆ Double()

Double::Double ( double _d)
inline

Definition at line 148 of file Numeric.inl.

149{
150 __d = _d;
151}
double __d
Definition Numeric.h:194

Member Function Documentation

◆ parse() [1/2]

double Double::parse ( const wchar_t * _number)
static

Definition at line 846 of file Numeric.cpp.

848{
849 __DCL_ASSERT(_number != NULL);
850
851 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
852 throw new NumericConvertException(_number, 0, 0);
853 }
854
855 NumericConvertException::Error error = NumericConvertException::NoError;
856 errno = 0;
857 wchar_t* endptr = NULL;
858 double n = wcstod(_number, &endptr);
859 if (errno == ERANGE) {
860 if (+HUGE_VAL == n || -HUGE_VAL == n) {
861 error = NumericConvertException::Overflow;
862 }
863 else if (!(DBL_MIN < n)) {
864 error = NumericConvertException::Underflow;
865 }
866 }
867
868 if (NumericConvertException::NoError != error) {
869 throw new NumericConvertException(
870 error,
871 _number,
872 0
873 );
874 }
875
876 if ((endptr && *endptr != '\0') || errno == EINVAL) {
877 throw new NumericConvertException(
878 _number,
879 0,
880 endptr ? (endptr - _number) : 0
881 );
882 }
883
884 return (double) n;
885}
#define NULL
Definition Config.h:312
#define __DCL_ASSERT(expr)
Definition Object.h:394
#define __T(str)
Definition Object.h:60

◆ parse() [2/2]

double Double::parse ( const wchar_t * _number,
double _default )
static

Definition at line 887 of file Numeric.cpp.

888{
889 __DCL_ASSERT(_number != NULL);
890
891 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
892 return _default;
893 }
894
895 NumericConvertException::Error error = NumericConvertException::NoError;
896 errno = 0;
897 wchar_t* endptr = NULL;
898 double n = wcstod(_number, &endptr);
899 if (errno == ERANGE) {
900 if (+HUGE_VAL == n || -HUGE_VAL == n) {
901 error = NumericConvertException::Overflow;
902 }
903 else if (!(DBL_MIN < n)) {
904 error = NumericConvertException::Underflow;
905 }
906 }
907
908 if (NumericConvertException::NoError != error) {
909 return _default;
910 }
911
912 if ((endptr && *endptr != '\0') || errno == EINVAL) {
913 return _default;
914 }
915
916 return (double) n;
917}

◆ toByteString()

ByteString Double::toByteString ( double _f,
const char * _format )
static

Definition at line 919 of file Numeric.cpp.

920{
921 if (!_format)
922 _format = "%.16g";
923
924 __DCL_ASSERT(*_format != '\0');
925
926 return ByteString::format(_format, _d);
927}

◆ toString() [1/2]

String Double::toString ( ) const
inline

Definition at line 153 of file Numeric.inl.

154{
155 return Double::toString(__d, NULL);
156}
String toString() const
Definition Numeric.inl:153

◆ toString() [2/2]

String Double::toString ( double _d,
const wchar_t * _format )
static

Definition at line 836 of file Numeric.cpp.

837{
838 if (!_format)
839 _format = __T("%.16g");
840
841 __DCL_ASSERT(*_format != '\0');
842
843 return String::format(_format, _d);
844}

Member Data Documentation

◆ __d

double Double::__d

Definition at line 194 of file Numeric.h.


The documentation for this class was generated from the following files: