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



This works fine here ....

d a s 15a inz('0009671180')
d s s 32s15

/free

s = %dec(a:63:5) / 100000;
dsply %char(s);


On Mon, Mar 18, 2013 at 10:53 PM, DeLong, Eric <EDeLong@xxxxxxxxxxxxxxx>wrote:

Hi Jeff,

Since the value in question itself is represented as an integer, and it
appears that you plan to simply divide that integer to derive the decimal
value you want, then you just need to fix the %DEC() bif... I'd probably
use %int() instead, since it does exactly as you would want...

The problem with using %dec( 'value' : 10 : 5 ) is that the api can't fit
your value into the five "whole digits" portion of your %dec() value...
(9671180 as an integer won't fit into 10.5

Hth
-Eric DeLong

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Jeff Young
Sent: Monday, March 18, 2013 4:31 PM
To: RPG programming on the IBM i / System i
Subject: Convert character to decimal

All,
I have a character representation of a numeric field whose value is
'0009671180' .
This represents 96.71180.
When I attempt to convert it back to a decimal value, I get the following
message:
Message ID . . . . . . : RNX0103 Severity . . . . . . . :
99
Message type . . . . . :
Escape
Date sent . . . . . . : 18/03/13 Time sent . . . . . . :
16:24:25


Message . . . . : The target for a numeric operation is too small to
hold
the
result.
Cause . . . . . : An arithmetic operation resulted in a value which is
too
large to fit in the target. If this is a numeric expression, the
overflow
could be the result of the calculation of some intermediate
result.
Recovery . . . : Either make the target of the operation larger or, if
in
an expression, choose the precision of the operands in the expression
so
that intermediate value will fit into the intermediate
result.

The code I am using is:
<snip>
D Work_Rate S 63 15
,
,
/Free
.
.
.
Monitor;
Work_Rate = (%Dec(Oh@AirRate : 10 : 5) / 100000);
$Air_Rate = Work_Rate;
On-Error;
$Air_Rate = *Zero;
EndMon;
</snip>

Since I made my work field more than large enough to hold the result, why
am I receiving this error?

Thanks,


--
Jeff Young
Sr. Programmer Analyst
--
This is the RPG programming on the IBM i (AS/400 and 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 IBM i (AS/400 and 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.