Numerics Class Reference

#include <Numerics.hpp>

Static Public Member Functions

static RexxObjectwholenumberToObject (wholenumber_t v)
 
static RexxObjectstringsizeToObject (stringsize_t v)
 
static RexxObjectint64ToObject (int64_t v)
 
static RexxObjectuint64ToObject (uint64_t v)
 
static RexxObjectuintptrToObject (uintptr_t v)
 
static RexxObjectintptrToObject (intptr_t v)
 
static bool objectToWholeNumber (RexxObject *o, wholenumber_t &result, wholenumber_t max, wholenumber_t min)
 
static bool objectToStringSize (RexxObject *o, stringsize_t &result, stringsize_t max)
 
static bool objectToSignedInteger (RexxObject *o, ssize_t &result, ssize_t max, ssize_t min)
 
static bool objectToUnsignedInteger (RexxObject *o, size_t &result, size_t max)
 
static bool objectToInt64 (RexxObject *o, int64_t &result)
 
static bool objectToUnsignedInt64 (RexxObject *o, uint64_t &result)
 
static bool objectToUintptr (RexxObject *source, uintptr_t &result)
 
static bool objectToIntptr (RexxObject *source, intptr_t &result)
 
static RexxObjectint64Object (RexxObject *source)
 
static size_t formatWholeNumber (wholenumber_t integer, char *dest)
 
static size_t formatStringSize (stringsize_t integer, char *dest)
 
static size_t formatInt64 (int64_t integer, char *dest)
 
static size_t formatUnsignedInt64 (uint64_t integer, char *dest)
 
static size_t normalizeWholeNumber (wholenumber_t integer, char *dest)
 
static size_t digits ()
 
static size_t fuzz ()
 
static bool form ()
 
static void setCurrentSettings (NumericSettings *s)
 
static NumericSettingssetDefaultSettings ()
 
static NumericSettingsgetDefaultSettings ()
 
static wholenumber_t abs (wholenumber_t n)
 
static wholenumber_t minVal (wholenumber_t n1, wholenumber_t n2)
 
static stringsize_t minVal (stringsize_t n1, stringsize_t n2)
 
static wholenumber_t maxVal (wholenumber_t n1, wholenumber_t n2)
 
static stringsize_t maxVal (stringsize_t n1, stringsize_t n2)
 
static wholenumber_t maxValueForDigits (size_t d)
 
static wholenumber_t multiplierForExponent (size_t e)
 
static RexxStringpointerToString (void *)
 

Static Public Attributes

static const wholenumber_t MAX_WHOLENUMBER = 999999999
 
static const wholenumber_t MIN_WHOLENUMBER = -999999999
 
static const wholenumber_t MAX_EXPONENT = 999999999
 
static const wholenumber_t MIN_EXPONENT = -999999999
 
static const size_t DEFAULT_DIGITS = ((size_t)9)
 
static const size_t ARGUMENT_DIGITS = ((size_t)9)
 
static const size_t SIZE_DIGITS = ((size_t)10)
 
static const size_t MAX_STRINGSIZE = MAX_WHOLENUMBER
 
static const size_t DIGITS64 = ((size_t)20)
 
static const bool FORM_SCIENTIFIC = false
 
static const bool FORM_ENGINEERING = true
 
static const size_t DEFAULT_FUZZ = ((size_t)0)
 
static const bool DEFAULT_FORM = Numerics::FORM_SCIENTIFIC
 
static const wholenumber_t validMaxWhole []
 

Static Protected Attributes

static NumericSettingssettings = &Numerics::defaultSettings
 
static NumericSettings defaultSettings
 

Detailed Description

Definition at line 59 of file Numerics.hpp.

Member Function Documentation

◆ abs()

◆ digits()

static size_t Numerics::digits ( )
inlinestatic

Definition at line 109 of file Numerics.hpp.

References NumericSettings::digits, and settings.

Referenced by number_digits().

◆ form()

static bool Numerics::form ( )
inlinestatic

Definition at line 111 of file Numerics.hpp.

References NumericSettings::form, and settings.

Referenced by number_form().

◆ formatInt64()

stringsize_t Numerics::formatInt64 ( int64_t  integer,
char *  dest 
)
static

Do portable formatting of an int64_t value into an ascii string.

Parameters
integerThe value to convert.
destThe location to store the formatted string.
Returns
The length of the converted number.

Definition at line 739 of file Numerics.cpp.

References integer().

Referenced by RexxDateTime::formatBaseTime(), RexxDateTime::formatTimeZone(), and RexxDateTime::formatUnixTime().

◆ formatStringSize()

stringsize_t Numerics::formatStringSize ( stringsize_t  integer,
char *  dest 
)
static

Do portable formatting of a stringsize value into an ascii string.

Parameters
integerThe value to convert.
destThe location to store the formatted string.
Returns
The length of the converted number.

Definition at line 698 of file Numerics.cpp.

References integer().

Referenced by RexxNumberString::formatUnsignedNumber().

◆ formatUnsignedInt64()

stringsize_t Numerics::formatUnsignedInt64 ( uint64_t  integer,
char *  dest 
)
static

Do portable formatting of a uint64_t value into an ascii string.

Parameters
integerThe value to convert.
destThe location to store the formatted string.
Returns
The length of the converted number.

Definition at line 804 of file Numerics.cpp.

References integer().

◆ formatWholeNumber()

stringsize_t Numerics::formatWholeNumber ( wholenumber_t  integer,
char *  dest 
)
static

Do portable formatting of a wholenumber value into an ascii string.

Parameters
integerThe value to convert.
destThe location to store the formatted string.
Returns
The length of the converted number.

Definition at line 572 of file Numerics.cpp.

References integer().

Referenced by RexxCompoundTail::buildTail(), RexxInteger::copyIntoTail(), RexxNumberString::formatInternal(), RexxInteger::primitiveMakeString(), RexxInteger::stringValue(), and RexxNumberString::stringValue().

◆ fuzz()

static size_t Numerics::fuzz ( )
inlinestatic

Definition at line 110 of file Numerics.hpp.

References NumericSettings::fuzz, and settings.

Referenced by number_fuzz().

◆ getDefaultSettings()

static NumericSettings* Numerics::getDefaultSettings ( )
inlinestatic

◆ int64Object()

RexxObject * Numerics::int64Object ( RexxObject source)
static

Validate that an object can be converted to an int64_t value

Parameters
sourceThe source object.
Returns
Returns an object that has been validated as a valid int64_t value and can be passed to a native routine. Returns null if this object is not valid.

Definition at line 447 of file Numerics.cpp.

References DIGITS64, RexxNumberString::int64Value(), isInteger(), RexxObject::numberString(), and OREF_NULL.

Referenced by optionalBigIntegerArg(), and requiredBigIntegerArg().

◆ int64ToObject()

RexxObject * Numerics::int64ToObject ( int64_t  v)
static

Convert a signed int64 object into the appropriate Rexx object type.

Parameters
vThe value to convert.
Returns
The Rexx object version of this number.

Definition at line 140 of file Numerics.cpp.

References MIN_WHOLENUMBER, new_integer(), and new_numberstringFromInt64().

Referenced by Int64ToObject(), RexxNativeActivation::int64Value(), RexxNativeActivation::unsignedInt64Value(), and RexxNativeActivation::valueToObject().

◆ intptrToObject()

RexxObject * Numerics::intptrToObject ( intptr_t  v)
static

Convert an signed ptr value into the appropriate Rexx object type.

Parameters
vThe value to convert.
Returns
The Rexx object version of this number.

Definition at line 866 of file Numerics.cpp.

References MAX_WHOLENUMBER, MIN_WHOLENUMBER, new_integer(), and new_numberstringFromWholenumber().

Referenced by IntptrToObject().

◆ maxVal() [1/2]

static stringsize_t Numerics::maxVal ( stringsize_t  n1,
stringsize_t  n2 
)
inlinestatic

Definition at line 119 of file Numerics.hpp.

◆ maxVal() [2/2]

◆ maxValueForDigits()

static wholenumber_t Numerics::maxValueForDigits ( size_t  d)
inlinestatic

◆ minVal() [1/2]

static stringsize_t Numerics::minVal ( stringsize_t  n1,
stringsize_t  n2 
)
inlinestatic

Definition at line 117 of file Numerics.hpp.

◆ minVal() [2/2]

◆ multiplierForExponent()

static wholenumber_t Numerics::multiplierForExponent ( size_t  e)
inlinestatic

Definition at line 132 of file Numerics.hpp.

References validMaxWhole.

◆ normalizeWholeNumber()

stringsize_t Numerics::normalizeWholeNumber ( wholenumber_t  integer,
char *  dest 
)
static

Do portable formatting of a wholenumber value into numberstring format.

Parameters
integerThe value to convert.
destThe location to store the formatted string.
Returns
The length of the converted number.

Definition at line 637 of file Numerics.cpp.

References integer().

Referenced by RexxNumberString::formatNumber().

◆ objectToInt64()

bool Numerics::objectToInt64 ( RexxObject source,
int64_t result 
)
static

Convert an object into a signed int64 value.

Parameters
sourceThe source object.
resultThe returned converted value.
Returns
true if the number converted properly, false for any conversion errors.

Definition at line 409 of file Numerics.cpp.

References DIGITS64, RexxNumberString::int64Value(), isInteger(), RexxObject::numberString(), and OREF_NULL.

Referenced by BUILTIN(), RexxNativeActivation::int64Value(), ObjectToInt64(), and RexxNativeActivation::objectToValue().

◆ objectToIntptr()

bool Numerics::objectToIntptr ( RexxObject source,
intptr_t result 
)
static

Convert an object into an intptr_t values. Used for values that are numbers masking as pointers.

Parameters
sourceThe source object.
resultThe returned value.
Returns
true if this converted, false for any conversion failures.

Definition at line 549 of file Numerics.cpp.

References INTPTR_MAX, INTPTR_MIN, and objectToSignedInteger().

Referenced by ObjectToIntptr(), and RexxNativeActivation::objectToValue().

◆ objectToSignedInteger()

bool Numerics::objectToSignedInteger ( RexxObject source,
ssize_t result,
ssize_t  maxValue,
ssize_t  minValue 
)
static

Convert an object into a signed integer value.

Parameters
sourceThe source object.
resultThe returned converted value.
maxValueThe maximum range value for the target.
minValueThe minimum range value for this number.
Returns
true if the number converted properly, false for any conversion errors.

Definition at line 269 of file Numerics.cpp.

References RexxNumberString::int64Value(), isInteger(), RexxObject::numberString(), OREF_NULL, and SIZE_DIGITS.

Referenced by ObjectToInt32(), objectToIntptr(), RexxNativeActivation::objectToValue(), and RexxNativeActivation::signedIntegerValue().

◆ objectToStringSize()

bool Numerics::objectToStringSize ( RexxObject source,
stringsize_t result,
stringsize_t  maxValue 
)
static

Convert an object into an unsigned number value.

Parameters
sourceThe source object.
resultThe returned converted value.
maxValueThe maximum range value for the target.
Returns
true if the number converted properly, false for any conversion errors.

Definition at line 312 of file Numerics.cpp.

References ARGUMENT_DIGITS, isInteger(), RexxObject::numberString(), OREF_NULL, and RexxNumberString::unsignedInt64Value().

Referenced by ObjectToStringSize(), and RexxNativeActivation::objectToValue().

◆ objectToUintptr()

bool Numerics::objectToUintptr ( RexxObject source,
uintptr_t result 
)
static

Convert an object into an uintptr_t values. Used for values that are numbers masking as pointers.

Parameters
sourceThe source object.
resultThe returned value.
Returns
true if this converted, false for any conversion failures.

Definition at line 526 of file Numerics.cpp.

References objectToUnsignedInteger(), and UINTPTR_MAX.

Referenced by ObjectToUintptr(), and RexxNativeActivation::objectToValue().

◆ objectToUnsignedInt64()

bool Numerics::objectToUnsignedInt64 ( RexxObject source,
uint64_t result 
)
static

Convert an object into an unsigned int64 value.

Parameters
sourceThe source object.
resultThe returned converted value.
Returns
true if the number converted properly, false for any conversion errors.

Definition at line 483 of file Numerics.cpp.

References DIGITS64, isInteger(), RexxObject::numberString(), OREF_NULL, and RexxNumberString::unsignedInt64Value().

Referenced by ObjectToUnsignedInt64(), RexxNativeActivation::objectToValue(), and RexxNativeActivation::unsignedInt64Value().

◆ objectToUnsignedInteger()

bool Numerics::objectToUnsignedInteger ( RexxObject source,
size_t &  result,
size_t  maxValue 
)
static

Convert an object into an unsigned number value.

Parameters
sourceThe source object.
resultThe returned converted value.
maxValueThe maximum range value for the target.
Returns
true if the number converted properly, false for any conversion errors.

Definition at line 361 of file Numerics.cpp.

References isInteger(), RexxObject::numberString(), OREF_NULL, SIZE_DIGITS, and RexxNumberString::unsignedInt64Value().

Referenced by objectToUintptr(), ObjectToUnsignedInt32(), RexxNativeActivation::objectToValue(), and RexxNativeActivation::unsignedIntegerValue().

◆ objectToWholeNumber()

bool Numerics::objectToWholeNumber ( RexxObject source,
wholenumber_t result,
wholenumber_t  maxValue,
wholenumber_t  minValue 
)
static

Convert an object into a whole number value.

Parameters
sourceThe source object.
resultThe returned converted value.
maxValueThe maximum range value for the target.
minValueThe minimum range value for this number.
Returns
true if the number converted properly, false for any conversion errors.

Definition at line 226 of file Numerics.cpp.

References ARGUMENT_DIGITS, RexxNumberString::int64Value(), isInteger(), RexxObject::numberString(), and OREF_NULL.

Referenced by RexxNativeActivation::objectToValue(), and ObjectToWholeNumber().

◆ pointerToString()

RexxString * Numerics::pointerToString ( void *  p)
static

Format a pointer into a string value using a consistent formatting style.

Parameters
pThe pointer valut to format.
Returns
The pointer as a string value in the format 0xnnnnnnnn.

Definition at line 888 of file Numerics.cpp.

References new_string().

Referenced by RexxPointer::stringValue(), and RexxNativeActivation::valueToObject().

◆ setCurrentSettings()

static void Numerics::setCurrentSettings ( NumericSettings s)
inlinestatic

◆ setDefaultSettings()

static NumericSettings* Numerics::setDefaultSettings ( )
inlinestatic

Definition at line 113 of file Numerics.hpp.

References defaultSettings, and settings.

Referenced by RexxActivity::releaseAccess().

◆ stringsizeToObject()

RexxObject * Numerics::stringsizeToObject ( stringsize_t  v)
static

Convert an unsigned number value into the appropriate Rexx object type.

Parameters
vThe value to convert.
Returns
The Rexx object version of this number.

Definition at line 203 of file Numerics.cpp.

References MAX_WHOLENUMBER, new_integer(), and new_numberstringFromStringsize().

Referenced by StringSizeToObject(), UnsignedInt32ToObject(), RexxNativeActivation::unsignedIntegerValue(), and RexxNativeActivation::valueToObject().

◆ uint64ToObject()

RexxObject * Numerics::uint64ToObject ( uint64_t  v)
static

Convert a signed int64 object into the appropriate Rexx object type.

Parameters
vThe value to convert.
Returns
The Rexx object version of this number.

Definition at line 161 of file Numerics.cpp.

References MAX_WHOLENUMBER, new_integer(), and new_numberstringFromUint64().

Referenced by UnsignedInt64ToObject(), and RexxNativeActivation::valueToObject().

◆ uintptrToObject()

RexxObject * Numerics::uintptrToObject ( uintptr_t  v)
static

Convert an unsigned ptr value into the appropriate Rexx object type.

Parameters
vThe value to convert.
Returns
The Rexx object version of this number.

Definition at line 844 of file Numerics.cpp.

References MAX_WHOLENUMBER, new_integer(), and new_numberstringFromStringsize().

Referenced by UintptrToObject().

◆ wholenumberToObject()

RexxObject * Numerics::wholenumberToObject ( wholenumber_t  v)
static

Convert an signed number value into the appropriate Rexx object type.

Parameters
vThe value to convert.
Returns
The Rexx object version of this number.

Definition at line 182 of file Numerics.cpp.

References MIN_WHOLENUMBER, new_integer(), and new_numberstringFromWholenumber().

Referenced by Int32ToObject(), RexxNativeActivation::signedIntegerValue(), RexxNativeActivation::valueToObject(), and WholeNumberToObject().

Member Data Documentation

◆ ARGUMENT_DIGITS

◆ DEFAULT_DIGITS

◆ DEFAULT_FORM

const bool Numerics::DEFAULT_FORM = Numerics::FORM_SCIENTIFIC
static

◆ DEFAULT_FUZZ

const size_t Numerics::DEFAULT_FUZZ = ((size_t)0)
static

◆ defaultSettings

NumericSettings Numerics::defaultSettings
staticprotected

Definition at line 143 of file Numerics.hpp.

Referenced by getDefaultSettings(), and setDefaultSettings().

◆ DIGITS64

◆ FORM_ENGINEERING

const bool Numerics::FORM_ENGINEERING = true
static

◆ FORM_SCIENTIFIC

◆ MAX_EXPONENT

◆ MAX_STRINGSIZE

const stringsize_t Numerics::MAX_STRINGSIZE = MAX_WHOLENUMBER
static

◆ MAX_WHOLENUMBER

◆ MIN_EXPONENT

const wholenumber_t Numerics::MIN_EXPONENT = -999999999
static

◆ MIN_WHOLENUMBER

◆ settings

NumericSettings * Numerics::settings = &Numerics::defaultSettings
staticprotected

Definition at line 142 of file Numerics.hpp.

Referenced by digits(), form(), fuzz(), setCurrentSettings(), and setDefaultSettings().

◆ SIZE_DIGITS

const size_t Numerics::SIZE_DIGITS = ((size_t)10)
static

Definition at line 71 of file Numerics.hpp.

Referenced by objectToSignedInteger(), and objectToUnsignedInteger().

◆ validMaxWhole

const wholenumber_t Numerics::validMaxWhole
static
Initial value:
= {10,
100,
1000,
10000,
100000,
1000000,
10000000,
100000000,
1000000000}

Definition at line 83 of file Numerics.hpp.

Referenced by maxValueForDigits(), multiplierForExponent(), RexxInteger::numberValue(), and RexxInteger::unsignedNumberValue().


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