|
| webMethods Ezine: Float and Double: 1/3 + 2/3 = 0.9999999... |
|
| Author |
Message |
Dan Green
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, October 02, 2002 - 09:45 pm: |
|
Questions or comments about this webMethods Ezine article? Click here to read the original text. |
Rob Eamon (reamon)
New member Username: reamon Post Number: 2
Registered: 04-2003 Rating: N/A Votes: 0 (Vote!) | | Posted on Monday, May 05, 2003 - 05:16 pm: |
|
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 |
Murugaiyan Subramanian
New member Username: muru Post Number: 3
Registered: 01-2003 Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, May 07, 2003 - 02:39 pm: |
|
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. |
|
|
Advertise at wMUsers
|