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



Then whats the point in specifying digits and precision? Just convert what
is passed and throw the appropriate errors if it doesn't fit in the result
field.


Chris Bougher



                                                                                
                                                        
                      "Bob Cozzi"                                               
                                                        
                      <cozzi@xxxxxxxxx>         To:       "'RPG programming on 
the AS400 / iSeries'" <rpg400-l@xxxxxxxxxxxx>            
                      Sent by:                  cc:                             
                                                        
                      rpg400-l-bounces@m        Subject:  RE: Use of %DEC with 
unformatted character numerics                           
                      idrange.com                                               
                                                        
                                                                                
                                                        
                                                                                
                                                        
                      12/02/2004 01:41                                          
                                                        
                      PM                                                        
                                                        
                      Please respond to                                         
                                                        
                      RPG programming on                                        
                                                        
                      the AS400 /                                               
                                                        
                      iSeries                                                   
                                                        
                                                                                
                                                        
                                                                                
                                                        




Interesting problem.
Yes %DEC() only works the way you are expecting it to when the decimal
point
is in there... how else could it work?
I got it to do what you wanted, but it ain't pretty...

D szNum           S              7A   Inz('0000128')
D nVal            S              7P 2

C                   eval      nVal = %Dec(
C                                 %EditW(%Dec(szNum:7:0):'     .  '):7:2)

-Bob Cozzi


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Tyler, Matt
Sent: Thursday, December 02, 2004 12:17 PM
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.



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

Follow-Ups:

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.