DCL 4.0
Loading...
Searching...
No Matches
Single Class Reference

#include <Numeric.h>

Public Member Functions

 Single (float _f)
String toString () const

Static Public Member Functions

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

Public Attributes

float __f

Detailed Description

Definition at line 147 of file Numeric.h.

Constructor & Destructor Documentation

◆ Single()

Single::Single ( float _f)
inline

Definition at line 130 of file Numeric.inl.

131{
132 __f = _f;
133}
float __f
Definition Numeric.h:150

Member Function Documentation

◆ parse() [1/2]

float Single::parse ( const wchar_t * _number)
static

Definition at line 728 of file Numeric.cpp.

730{
731 __DCL_ASSERT(_number != NULL);
732
733 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
734 throw new NumericConvertException(_number, 0, 0);
735 }
736
737 NumericConvertException::Error error = NumericConvertException::NoError;
738 wchar_t* endptr = NULL;
739 float n = wcstof(_number, &endptr);
740 if (+HUGE_VALF == n || -HUGE_VALF == n) {
741 error = NumericConvertException::Overflow;
742 } else if (!(FLT_MIN < n)) {
743 error = NumericConvertException::Underflow;
744 }
745
746 if (NumericConvertException::NoError != error) {
747 throw new NumericConvertException(
748 error,
749 _number,
750 0
751 );
752 }
753
754 if ((endptr && *endptr != '\0') || errno == EINVAL) {
755 throw new NumericConvertException(
756 _number,
757 0,
758 endptr ? (endptr - _number) : 0
759 );
760 }
761
762 return (float) n;
763}
#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]

float Single::parse ( const wchar_t * _number,
float _default )
static

Definition at line 765 of file Numeric.cpp.

766{
767 __DCL_ASSERT(_number != NULL);
768
769 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
770 return _default;
771 }
772
773 NumericConvertException::Error error = NumericConvertException::NoError;
774 wchar_t* endptr = NULL;
775 float n = wcstof(_number, &endptr);
776 if (+HUGE_VALF == n || -HUGE_VALF == n) {
777 error = NumericConvertException::Overflow;
778 } else if (!(FLT_MIN < n)) {
779 error = NumericConvertException::Underflow;
780 }
781
782 if (NumericConvertException::NoError != error) {
783 return _default;
784 }
785
786 if ((endptr && *endptr != '\0') || errno == EINVAL) {
787 return _default;
788 }
789
790 return (float) n;
791}

◆ toByteString()

ByteString Single::toByteString ( float _f,
const char * _format )
static

Definition at line 793 of file Numeric.cpp.

794{
795 if (!_format)
796 _format = _f < INT64_MIN || INT64_MAX < _f ? "%e" : "%f";
797
798 __DCL_ASSERT(*_format != '\0');
799
800 return ByteString::format(_format, _f);
801}
#define INT64_MIN
Definition Config.h:314
#define INT64_MAX
Definition Config.h:319

◆ toString() [1/2]

String Single::toString ( ) const
inline

Definition at line 135 of file Numeric.inl.

136{
137 return Single::toString(__f, NULL);
138}
String toString() const
Definition Numeric.inl:135

◆ toString() [2/2]

String Single::toString ( float _f,
const wchar_t * _format )
static

Definition at line 718 of file Numeric.cpp.

719{
720 if (!_format)
721 _format = _f < INT64_MIN || INT64_MAX < _f ? __T("%e") : __T("%f");
722
723 __DCL_ASSERT(*_format != '\0');
724
725 return String::format(_format, _f);
726}

Member Data Documentation

◆ __f

float Single::__f

Definition at line 150 of file Numeric.h.


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