convert Double Precision number (8F)

Tags:
AS/400
Double Precision Number (8F)
iSeries
How would I convert a Double Precision number (that is 8F). I am using a random number generator that return the random number in this field define as 8F. I need to have the result be move to a 5 character field for printing on a label.
ASKED: April 28, 2009  5:15 PM
UPDATED: April 29, 2009  1:01 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi AS400PCFileTransfer16

The demo code below assumes that your random number generator creates
a number from 0 to .99999999999999999
1. Convert to signed or packed
2. Convert to character
3. Substring to desired length

D valuef8 s 8f inz(0.1234567891)
D values150 s 15s 0
D valuec15 s 15a
D valuec5 s 5a
C valuef8 dsply
C eval values150 = valuef8 * 1000000000000000
C values150 dsply
C eval valuec15 = %editc(values150 : ‘X’)
C valuec15 dsply
C eval valuec5 = %subst(valuec15 : 1 : 5)
C valuec5 dsply
C
C eval *inof = *on
C return

Phil

Discuss This Question:  

 
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

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