× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Matt

The decimal point is optional, but not implied.  In other words '0000128'
would be 128.00 as would '0128.00' (both 7 character strings).  If the
decimal point isn't specified then it's taken as falling after the last
character in the string.

You should either use the MOVE opcode or divide the result by 100, e.g:

        Eval Number = %Dec(String)/100

Hope it helps

Jonathan
www.astradyne-uk.com

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Tyler, Matt
Sent: 02 December 2004 18:17
To: 'RPG programming on the AS400 / iSeries'
Subject: Use of %DEC with unformatted character numerics


I have a number in a character parameter 7a ('0000128') and I want to use
%DEC() to convert that to a packed 7.2 field.  However, I get 128.00
instead.  The reference manual is not completely clear on the decimal point
requirements for a character string numeric.

        "The decimal point is optional. It can be either a period or a
comma."

Is the decimal point optional in that it can be either a period or a comma
or is it optional completely, be a period or be a comma?

If %DEC() is treating my number as a whole number then I must say that I
have been highly disappointed in the new features added to V5.2 for %DEC().


We often pass numeric data between programs in character fields (no comment
please if you don't agree with this) and convert them back to numeric.  We
rarely include the decimal point since the only method to date was to use
MOVE to convert it back to numeric.

I would prefer to not have to do this just to use %DEC() if the decimal
point is required in order for %DEC() to format the value as 1.28.
/FREE
   CDSRTL = %DEC(%subst(PASSSUGRTL:1:5)+'.'+%subst(PASSSUGRTL:6:2):7:2);
/END-FREE


Thank you,
Matt Tyler
WinCo Foods, Inc
mattt@xxxxxxxxxxxxxx

--
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 thread ...

Replies:

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

This mailing list archive is Copyright 1997-2024 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.