Kbase P125252: How to convert a decimal number to a string that has no decimal point while keeping the first two di
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  18/04/2011 |
|
Status: Verified
GOAL:
How to convert a decimal number to a string that has no decimal point while keeping the first two digits from the original decimal part?
GOAL:
How to write a special purpose function that takes a decimal number and returns the STRING of the integer part and the first two digits of the decimal part without the decimal point or rounding the decimal?
FACT(s) (Environment):
Progress 9.x
OpenEdge 10.x
All Supported Operating Systems
FIX:
This is a special purpose function that takes a decimal number whose format is made of an integer part and a decimal part separated by the SESSION:NUMERIC-DECIMAL-POINT character (the period '.' in the USA, a comma ',' in some other countries) and returns the integer part and the first two digits (without rounding) of the decimal part:
FUNCTION getString RETURNS CHARACTER (INPUT ipdDecimal AS DECIMAL) FORWARD.
MESSAGE getString(1234567890.1)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
MESSAGE getString(1234567890.12)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
MESSAGE getString(1234567890.123)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
FUNCTION getString RETURNS CHARACTER (INPUT ipdDecimal AS DECIMAL):
RETURN STRING(TRUNCATE(ipdDecimal * 100,0)).
END.