DCL 4.0
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 173 of file Numeric.h.

Constructor & Destructor Documentation

◆ Double()

Double::Double ( double _d)
inline

Definition at line 142 of file Numeric.inl.

143{
144 __d = _d;
145}
double __d
Definition Numeric.h:176

Member Function Documentation

◆ parse() [1/2]

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

Definition at line 826 of file Numeric.cpp.

828{
829 __DCL_ASSERT(_number != NULL);
830
831 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
832 throw new NumericConvertException(_number, 0, 0);
833 }
834
835 NumericConvertException::Error error = NumericConvertException::NoError;
836 wchar_t* endptr = NULL;
837 double n = wcstod(_number, &endptr);
838 if (+HUGE_VAL == n || -HUGE_VAL == n) {
839 error = NumericConvertException::Overflow;
840 } else if (!(DBL_MIN < n)) {
841 error = NumericConvertException::Underflow;
842 }
843
844 if (NumericConvertException::NoError != error) {
845 throw new NumericConvertException(
846 error,
847 _number,
848 0
849 );
850 }
851
852 if ((endptr && *endptr != '\0') || errno == EINVAL) {
853 throw new NumericConvertException(
854 _number,
855 0,
856 endptr ? (endptr - _number) : 0
857 );
858 }
859
860 return (double) n;
861}
#define NULL
Definition Config.h:340
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define __T(str)
Definition Object.h:44
void CharsetConvertException *size_t n
Definition SQLField.cpp:253

◆ parse() [2/2]

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

Definition at line 863 of file Numeric.cpp.

864{
865 __DCL_ASSERT(_number != NULL);
866
867 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
868 return _default;
869 }
870
871 NumericConvertException::Error error = NumericConvertException::NoError;
872 wchar_t* endptr = NULL;
873 double n = wcstod(_number, &endptr);
874 if (+HUGE_VAL == n || -HUGE_VAL == n) {
875 error = NumericConvertException::Overflow;
876 } else if (!(DBL_MIN < n)) {
877 error = NumericConvertException::Underflow;
878 }
879
880 if (NumericConvertException::NoError != error) {
881 return _default;
882 }
883
884 if ((endptr && *endptr != '\0') || errno == EINVAL) {
885 return _default;
886 }
887
888 return (double) n;
889}

◆ toByteString()

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

Definition at line 891 of file Numeric.cpp.

892{
893 if (!_format)
894 _format = _d < INT64_MIN || INT64_MAX < _d ? "%e" : "%f";
895
896 __DCL_ASSERT(*_format != '\0');
897
898 return ByteString::format(_format, _d);
899}
#define INT64_MIN
Definition Config.h:314
#define INT64_MAX
Definition Config.h:319

◆ toString() [1/2]

String Double::toString ( ) const
inline

Definition at line 147 of file Numeric.inl.

148{
149 return Double::toString(__d, NULL);
150}
String toString() const
Definition Numeric.inl:147

◆ toString() [2/2]

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

Definition at line 816 of file Numeric.cpp.

817{
818 if (!_format)
819 _format = _d < INT64_MIN || INT64_MAX < _d ? __T("%e") : __T("%f");
820
821 __DCL_ASSERT(*_format != '\0');
822
823 return String::format(_format, _d);
824}

Member Data Documentation

◆ __d

double Double::__d

Definition at line 176 of file Numeric.h.


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