RPGNext
Take Your RPG Development to theNextLevel
Site Links
Home
RPG Programming
xRPG Downloads
xRPG Docs
About This Site
About Me

RPG Gurus
Bob Cozzi
Brad Stone
Scott Klement
Jon Paris

iSeries Links
Alpha Works
Midrange.com
FAQ@Midrange.com
MidrangeServer.com
IBM Docs
iSeries Infocenter
MCPress
Easy400
API Finder

xRPG Core Library Procedures - RNBMISC: decToFractions()


Convert Decimal Number to Fractional String Notation.

Usage:

decToFractions( decimal : {precision:*omit} : {simplify:*omit} : { {rounding:*omit} : {style:*omit} : {format:*omit} );

Name Type Options Opt/Req Description
decimal 30,9 Const Req The decimal to convert.
precision 5i 0 Const Opt:Omit The denominator of the fraction, such as 8ths, 27ths, etc. If *OMITted or <= 1 sent, then the procedure will intelligently calculate the fraction.
simplify N Const Opt:Omit Indicates whether or not to naturally simplify the fraction. If precision <= 1 or *OMITted then simplification occurs by default.
  • *ON - Simplifies the fraction to the smallest possible value (DEFAULT): i.e. 4/8 becomes 1/2.
  • *OFF- Leaves the value as calculated: i.e. 4/8 remains 4/8.
rounding 5A Const Opt:Omit Instructs the procedure how to handle rounding of partial decimal values as related to precision.
  • 'calc' = intelligent rounding (DEFAULT)
  • 'up' = always round up
  • 'down' = always round down.
EX: 3.32 is 3 and 5/16ths plus a little. This could round down to 5/16th or up tp 6/16th(3/8th). 'calc' will determine rounding based on whether or not the remainder is closer to 5/16th or 6/16ths.
style 10A Const Opt:Omit Specifys the style of the return value. The following values are currently supported:
  • 'numeric' (DEFAULT): EX. 38 1/8 or 57 7/16.
  • 'natural' : 38 AND 1/8TH or 57 AND 7/16THS.
  • 'verbose' : THIRTY-EIGHT AND ONE-EIGHTH or FIFTY-SEVEN AND SEVEN-SIXTEENTHS.
style 5A Const Opt:Omit Specifys the format of the return value. Only used if 'style' parm = 'natural' or 'verbose'. The following values are currently supported:
  • 'upper' for all upper case (DEFAULT).
  • 'lower' for all lower case.
  • 'mixed' for mixed case.
Returns: 32767A Varying n/a The fractional string notation of the decimal.

This site conforms with the following W3C specifications:

Web Essentials

Contact