Move equivalent in Free format. %dec is not getting the expected result

2,410 pts.
Tags:
AS/400
I have a character field (CharA) of 13A. I want to convert it to a packed decimal field (13,5) Value in charA is '0000000750000' and I want the value in Numeric field as 00000007.50000 I have used %Dec(CharA:13:5), but the value am getting is 00750000.00000. I am using Free format, I am able to achieve the correct result using Move, but then I had to switch back to fixed format.

Software/Hardware used:
AS400 RPG
ASKED: August 3, 2013  11:55 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    ...the value am getting is 00750000.00000...   That's the value that you have in the CharA field, so it's exactly what you should get. Your CharA field doesn't have a decimal point in it, so it's an integer value. If you want the value to be 7.5, then you'll need to divide by 100000.   As a faster alternative, you could redefine your Numeric field with a second 13-digit packed field that has no decimal positions. That is, use the OVERLAY() keyword. When you put %DEC() into the new field, you can then retrieve the value from the original Numeric field. Since the two fields both have 13 digits and both are packed and refer to the same memory, you can use the data redefinition without needing to execute a division operation.   Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    or%Dec(%subst(CharA:1:8) + '.' + %subst(CharA:9:5):13:5)
    48,565 pointsBadges:
    report
  • TomLiotta
    I tend to prefer data definitions rather than executable instructions. But %DEC() can allow variables for precision and decimals, and that can be useful. -- Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following