Re: Vector processing instructions

2017-08-09 Thread John P. Baker
Amrith,

Converting a 128-bit unsigned fixed binary integer to packed decimal is not 
particularly difficult.

The following methodology should meet your needs -

IVFB - Input Value (128-bit Unsigned Fixed Binary)
WVFB - Working Value (128-bit Unsigned Fixed Binary)
AFPD - Adjustment Factor (11-byte Packed Decimal)
QUFB - Quotient (64-bit Unsigned Fixed Binary)
RMFB - Remainder (64-bit Unsigned Fixed Binary)
QUPD - Quotient (11-byte Packed Decimal)
RMPD - Remainder (10-byte Packed Decimal)
OVPD - Output Value (20-byte Packed Decimal)

WVFB = IVFB ;
AFPD = 0 ;
Do While (WVFB >= 100) ; /* (10**38) */
  WVFB = (WVFB - 100) ; /* (10**38) */
  AFPD = AFPD + 1000 ; /* (10**19) */
End ;
Do While (WVFB >= 9223372036854775807000) ; /* ((2**63) - 1) * 
(10**19) */
  WVFB = WVFB - 10 ; /* (10**37) */
  AFPD = AFPD + 100 ; /* (10**18) */
End ;
QUFB = WVFB / 1000 ; /* (10**19) ; Remainder in "RMFB" */
QUPD = QUFB ; /* Convert to Packed Decimal */
RMPD = RMFB ; /* Convert to Packed Decimal */
QUPD = QUPD + AFPD ;
OVPD = QUPD (20 digits)) || RMPD (19 digits) ;

Please note than in the last pseudo-code instruction, the 19 digits of RMPD + 
the sign field fill ten (10) bytes.  However, the sign field of QUPD must be 
ignored, so an MVO instruction can be used to shift the value one (1) nibble to 
the left.  The QUPD value (after discarding the rightmost byte) can be appended 
to the front of RMPD, giving you a 30-byte packed decimal value.  Please note 
that a packed decimal field of this length is NOT supported by IBM machine 
instructions except (I believe) for the ED/EDMK instructions ( I have not 
tested this).

The logic for converting a signed 128-bit value is slightly more complex, but 
is also do-able without any significant difficulty.

John P. Baker

-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Amrith
Sent: Sunday, August 6, 2017 9:49 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Vector processing instructions

Folks, 
   Recently I was working with vector processing on z13 and noticed that we 
have 128bit add and sub instructions but no multiply(correct me here but the 
multiply is on 64bit)  or divide. Any idea on how to convert the 128bit 
signed/unsigned binary integer to packed decimal. If anyone is working with the 
vector instructions on z13 please IM me. 

Thanks
Amrith 

--
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Vector processing instructions

2017-08-09 Thread Charles Mills
A 40-digit decimal number? Really?

The main advantage of binary integers is that they compute readily on a 
computer. The main advantage of decimal integers is that they are easy for 
humans to read. But 40-digit decimal numbers?

Charles

-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Amrith
Sent: Sunday, August 6, 2017 9:49 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Vector processing instructions

Folks, 
   Recently I was working with vector processing on z13 and noticed that we 
have 128bit add and sub instructions but no multiply(correct me here but the 
multiply is on 64bit)  or divide. Any idea on how to convert the 128bit 
signed/unsigned binary integer to packed decimal. If anyone is working with the 
vector instructions on z13 please IM me. 

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Vector processing instructions

2017-08-07 Thread Paul Gilmartin
On Mon, 7 Aug 2017 15:03:00 -0400, Steve Smith wrote:

>Maybe you could show your code.  MP and DP can be tricky, but when you
>CVDG the high D-word, you'd then multiply it by
>9,223,372,036,854,775,808, then by 2 (or something equivalent).  Add
>to what you CVDG from the low D-word.
>
>Of course, this will overflow if the value is too large for 31 digits,
>and may get PD multiply exceptions for much less.  You may have to do
>some weaseling to make it work.  Brute force would be multiplying the
>converted high D-word by 2 64 times.
>
... which still overflows.  Need to break the converted high D-word (which
can not exceed 20 digits) into two 10-bit chunks; multiply each by 2**64
(at most 30 digits), break the bottom one into tswo 10-digit pieces;
add the top 10 dights to the converted top half; and string everything
together.

This is simulating long multiplication.

-- gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Vector processing instructions

2017-08-07 Thread Steve Smith
Maybe you could show your code.  MP and DP can be tricky, but when you
CVDG the high D-word, you'd then multiply it by
9,223,372,036,854,775,808, then by 2 (or something equivalent).  Add
to what you CVDG from the low D-word.

Of course, this will overflow if the value is too large for 31 digits,
and may get PD multiply exceptions for much less.  You may have to do
some weaseling to make it work.  Brute force would be multiplying the
converted high D-word by 2 64 times.

sas

On Mon, Aug 7, 2017 at 12:51 PM, Paul Gilmartin
<000433f07816-dmarc-requ...@listserv.ua.edu> wrote:
> On Mon, 7 Aug 2017 11:17:05 -0500, Todd Arnold wrote:
>
>>I got this answer from someone else at IBM, who is an expert in the vector 
>>instructions:
>>"Currently to convert a 128-bit singed/unsigned integer in a vector register 
>>to a packed decimal value you must store the value to memory and use the 
>>standard integer conversion instruction CVBG to convert 64-bits at a time.  
>>...
>>
> Does "someone else" suggest working right-to-left or left-to-right?  And 
> there's
> a trick needed to cross the boundary since 2**64 is not a power of 10.  Would 
> I
> find an example if I RTFM PoOps?
>
>>... A full 128-bit value will not fit into a 31-digit decimal number."
>>
> ... a tautology, since
> 2**127: 170141183460469231731687303715884105728
> ... is greater than
> 10**31:1000
>
> -- gil
>
> --
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN



-- 
sas

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Vector processing instructions

2017-08-07 Thread Paul Gilmartin
On Mon, 7 Aug 2017 11:17:05 -0500, Todd Arnold wrote:

>I got this answer from someone else at IBM, who is an expert in the vector 
>instructions:
>"Currently to convert a 128-bit singed/unsigned integer in a vector register 
>to a packed decimal value you must store the value to memory and use the 
>standard integer conversion instruction CVBG to convert 64-bits at a time.  ...
>
Does "someone else" suggest working right-to-left or left-to-right?  And there's
a trick needed to cross the boundary since 2**64 is not a power of 10.  Would I
find an example if I RTFM PoOps?

>... A full 128-bit value will not fit into a 31-digit decimal number."
>
... a tautology, since
2**127: 170141183460469231731687303715884105728
... is greater than 
10**31:1000

-- gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Vector processing instructions

2017-08-07 Thread Amrith
Thanks Todd. I think you are referring to CVDG which is what I had used but 
didn't yield the expected  results. Splitting a 128bit binary integer into 2 
64bits and then a CVDG didn't convert it as expected. I will probably try that 
out again. I used Java Big Integer for a simple 128bit arithmetic  and the 
outputs from z13 and Java did not match.  



On Mon, 8/7/17, Todd Arnold <arno...@us.ibm.com> wrote:

 Subject: Re: Vector processing instructions
 To: IBM-MAIN@LISTSERV.UA.EDU
 Date: Monday, August 7, 2017, 4:17 PM
 
 I got this answer from someone else at IBM,
 who is an expert in the vector instructions:
 "Currently to convert a 128-bit
 singed/unsigned integer in a vector register to a packed
 decimal value you must store the value to memory and use the
 standard integer conversion instruction CVBG to convert
 64-bits at a time. A full 128-bit value will not fit into a
 31-digit decimal number."
 
 --
 For IBM-MAIN subscribe / signoff /
 archive access instructions,
 send email to lists...@listserv.ua.edu
 with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Vector processing instructions

2017-08-07 Thread Todd Arnold
I got this answer from someone else at IBM, who is an expert in the vector 
instructions:
"Currently to convert a 128-bit singed/unsigned integer in a vector register to 
a packed decimal value you must store the value to memory and use the standard 
integer conversion instruction CVBG to convert 64-bits at a time. A full 
128-bit value will not fit into a 31-digit decimal number."

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN