|
If you're on V5R2 you can just use %DEC you don't need to convert it to float. Just put the character field in the %DEC built-in. If you have RPG xTools use the CharToNum subprocedure to do the same thing: Eval myDecValue = CharToNum(MyCharValue) CharToNum doesn't care about the length, decimals blanks, or any of that crap. I think I also published this procedure and it may still be on my website if you don't have RPGxTools. -Bob -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Malchow, Grizzly Sent: Wednesday, March 09, 2005 4:27 PM To: rpg400-l@xxxxxxxxxxxx Subject: Convert Float to Dec I am converting an alphanumeric value to floating point and then I am converting the floating point to decimal. The character field I need to convert always has a decimal followed by 4 numbers. I don't know of any other way to convert an alphanumeric field and have the 4 decimal point precision. message: 2 date: Wed, 9 Mar 2005 14:43:19 -0600 from: "Bob Cozzi" <cozzi@xxxxxxxxx> subject: RE: Convert Float to Dec First, why bother moving it into floating point? Why not go directly to decimal? Eval DecPrice = FltPrice Second, for ATOF to work, you need the "E" embedded after the value. "2.2134E0" or something like that. -Bob -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.