Can't say I've tested every permutation of a decimal number represented in
a string, but I believe the 'atof' API will do what you need. I use it
for a similar purpose via the below prototype.

D CvtDec PR 8F ExtProc('atof')
D * Options(*String) Value

C Eval(h) MyDecField = CvtDec(MyCharField)

Kind Regards,

Joe Maguire




From:
James Lampert <jamesl@xxxxxxxxxxxxxxxxx>
To:
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
Date:
28/12/2008 19:00
Subject:
Converting a string to a number in RPG
Sent by:
rpg400-l-bounces@xxxxxxxxxxxx



Given a string representation of a number, zero-blanked (and possibly,
but not necessarily, even starting in the leftmost position) and with an
explicit decimal point (that may or may not be present), and a V5R3
target box,

e.g, "123.45" or " 1.23" or "1.23" or "1.2" or "123"

Is there some *easy* way my addled brain is overlooking, to parse that
into a fixed-decimal numeric field (zoned or packed)? Beyond just
looping through the character positions and building up the number,
digit by digit?


This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.