PDA

View Full Version : webMethods Ezine Float and Double 13 23 %3d 099999999


dgreen
10-02-2002, 21:45
Questions or comments about this webMethods Ezine article?

Click here (http://www.wmusers.com/ezine/2002oct1_reamon_1.shtml) to read the original text.

Rob Eamon (reamon)
05-05-2003, 17:16
In a previous post, MS wrote:
------
By MS on Friday, May 02, 2003 - 07:12 pm:

Rob,

I am working on a project where I have to work with
Packed-Decimals which comes from mainframe and send the
result as Packed-Decimals. I was going through the IBM
documentation which talks about this data type, they are
suggesting to use their enhanced BigDecimal class for the
packed decimal. They even provide this class which can be
downloaded from their site. The Class name is
com.ibm.math.BigDecimal. I am bit confused now on using the
java.math.BigDecimal

IBM explains why they had to develop their own class for
this.

http://www2.hursley.ibm.com/decimalj/decimald.html

Thanks,
Muru.
--------

Muru:

Working with packed decimals is fairly straight-forward. From your description, I assume you receive packed decimal(s), perform some sort of calculation and then return packed decimal to the mainframe.

You should be able to use either java.math.BigDecimal or com.ibm.math.BigDecimal with no trouble. The thing to do is to convert from packed decimal to BigDecimal, perform your calcs, and convert back to packed decimal. However, neither class provides direct support for packed decimal nor do they provide conversion to/from packed decimal. The class to choose for your calcs depends on whether or not it can support the calcs you need.

For readers that may not be familiar with packed decimal (defined at http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DZ9AR004/CCONTENTS) a packed decimal is a byte array in which each byte contains two decimal digits; the last byte has 1 decimal digit and a sign value.

You'll need to get or write some code that converts between this byte array and BigDecimal. What are you using to interact with the mainframe? That will determine how the byte array gets to/from your wM IS environment, where you can convert and calculate.

HTH

muru
05-07-2003, 14:39
Rob,

You are right the part I am having trouble is to convert the packed decimal to big decimal in other way I am not able to unpack the packed decimal. I am still looking to find some way we can unpack the packed decimal.

Thanks for your help,
Muru.