Namespace: OpenEdge.Core.Util
Type: Class MathUtil
Parent Classes:
Progress.Lang.Object

Inherits: Progress.Lang.Object


Copyright (c) 2014, 2017, 2020-2022 by Progress Software Corporation. All rights reserved.
File:MathUtil
Purpose:General-purpose maths functionality.
Author(s):pjudge
Created:Thu May 15 14:44:19 EDT 2014
/* Keep the default in a readonly property - it is 10



Method Summary
  Options Name Purpose
  INTEGER Ceiling (decimal) /** Return a ceiling value (a always-round-up value). So, 2.1 returns 3 1.9 returns 2 5.0 returns 5 @param decimal The value to adjust @return integer The ceiling value */
  DECIMAL ExponentialToDec (character) /** Converts an exponent (123e4) value into a decimal using a exponent base of 10. @param character The exponent value @param decimal The converted value */
  DECIMAL ExponentialToDec (character, integer) /** Converts an exponent (123e4) value into a decimal. The format is nnn[.nnn]e[-]nnn <base>e<exponent> The <exponent> is raised as a power of the exponent-base. @param character The exponent value @param integer The exponent base. Must be a positive value (>0) @param decimal The converted value */
  INT64 HexToInt (character) /** Converts hex to integer values @param character A hex value @return int64 The integer representation of that hex value. */
  INT64 HexToInt (character, DataTypeEnum) /* Converts a hex string to an integer or int64. The string cannot be longer than 8 (integer) or 16 (int64) characters. If shorter than that, the string is padded with '0'. @param character A hex string. @param DataTypeEnum The type of integer (integer or int64). @return int64 The integer return value. May contain an integer value */
  INTEGER HexToInt32 (character) /** Converts hex to integer values @param character A hex value @return integer The integer representation of that hex value. */
  CHARACTER IntToHex (int64) /** Converts an integer to a hex value. If the integer value is negative, then the hex value is padded with up to 7 F's, for a length of 8 characters. Positive integer values are returned wihtout any padding. Zero is '0'. The unknown value returns an empty string. @param integer An integer value. @return character A hex value. */
  CHARACTER IntToHex (int64, DataTypeEnum) /* Converts an integer value to a hex value @param int64 The integet value. Can hold an INTEGER or INT64 value. @param DataTypeEnum The type of integer (integer or int64). @return character The hex-encoded value */
  CHARACTER IntToHex (int64, integer) /** Converts a 64-bit integer to a padded hax value @param int64 An integer value @param integer The total length of the hex value. If the length of the hex value is larger than this, use the value as-is. If the length of the hex value is les, pad with leading zeros to make the link. Negative numbers will always be at least 8 characters long, and padded with F's. @return character A hex value */
  CHARACTER IntToHex (integer) /** Converts an integer to a hex value. If the integer value is negative, then the hex value is padded with up to 7 F's, for a length of 8 characters. Positive integer values are returned wihtout any padding. Zero is '0'. The unknown value returns an empty string. @param integer An integer value. @return character A hex value. */
  CHARACTER IntToHex (integer, integer) /** Converts an integer to a padded hex value @param integer An integer value @param integer The total length of the hex value. If the length of the hex value is larger than this, use the value as-is. If the length of the hex value is les, pad with leading zeros to make the link. Negative numbers will always be at least 8 characters long, and padded with F's. @return character A hex value */

Property Summary
  Options Name Purpose
  INTEGER DEFAULT_BASE


Method Detail
Top

INTEGER Ceiling (decimal)

Purpose: Return a ceiling value (a always-round-up value).
So,
2.1 returns 3
1.9 returns 2
5.0 returns 5
Parameters:
pdVal DECIMAL
 
Returns INTEGER
  integer The ceiling value
Top

DECIMAL ExponentialToDec (character)

Purpose: Converts an exponent (123e4) value into a decimal using a exponent
base of 10.
Parameters:
pExpVal CHARACTER
 
Returns DECIMAL
 
Top

DECIMAL ExponentialToDec (character, integer)

Purpose: Converts an exponent (123e4) value into a decimal.
The format is
nnn[.nnn]e[-]nnn
<base>e<exponent>
The <exponent> is raised as a power of the exponent-base.
Parameters:
pExpVal CHARACTER
 
pBase INTEGER
 
Returns DECIMAL
 
Top

INT64 HexToInt (character)

Purpose: Converts hex to integer values
Parameters:
pcHex CHARACTER
 
Returns INT64
  int64 The integer representation of that hex value.
Top

INT64 HexToInt (character, DataTypeEnum)

/* Converts a hex string to an integer or int64.
The string cannot be longer than 8 (integer) or 16 (int64) characters. If shorter than that, the string is
padded with '0'.
Parameters:
pHex CHARACTER
 
pDataType OpenEdge.Core.DataTypeEnum
 
Returns INT64
  int64 The integer return value. May contain an integer value
Top

INTEGER HexToInt32 (character)

Purpose: Converts hex to integer values
Parameters:
pcHex CHARACTER
 
Returns INTEGER
  integer The integer representation of that hex value.
Top

CHARACTER IntToHex (int64)

Purpose: Converts an integer to a hex value.
If the integer value is negative, then the hex value is padded with up to 7 F's, for a
length of 8 characters. Positive integer values are returned wihtout any padding. Zero is '0'.
The unknown value returns an empty string.
Parameters:
pValue INT64
 
Returns CHARACTER
  character A hex value.
Top

CHARACTER IntToHex (int64, DataTypeEnum)

/* Converts an integer value to a hex value
Parameters:
pValue INT64
 
pType OpenEdge.Core.DataTypeEnum
 
Returns CHARACTER
  character The hex-encoded value
Top

CHARACTER IntToHex (int64, integer)

Purpose: Converts a 64-bit integer to a padded hax value
use the value as-is. If the length of the hex value is les, pad with leading zeros to make
the link. Negative numbers will always be at least 8 characters long, and padded with F's.
Parameters:
pValue INT64
 
pPadding INTEGER
 
Returns CHARACTER
  character A hex value
Top

CHARACTER IntToHex (integer)

Purpose: Converts an integer to a hex value.
If the integer value is negative, then the hex value is padded with up to 7 F's, for a
length of 8 characters. Positive integer values are returned wihtout any padding. Zero is '0'.
The unknown value returns an empty string.
Parameters:
pValue INTEGER
 
Returns CHARACTER
  character A hex value.
Top

CHARACTER IntToHex (integer, integer)

Purpose: Converts an integer to a padded hex value
use the value as-is. If the length of the hex value is les, pad with leading zeros to make
the link. Negative numbers will always be at least 8 characters long, and padded with F's.
Parameters:
pValue INTEGER
 
pPadding INTEGER
 
Returns CHARACTER
  character A hex value


Property Detail
Top

INTEGER DEFAULT_BASE

Returns INTEGER