Join wMUsers | Blog at wMUsers | Edit my wMUsers Profile | Site Map | Invite your peers | webMethods Jobs | For Employers

webMethods Ezine: Float and Double: 1/3 + 2/3 = 0.9999999...

wMUsers Discussion Forums » If it doesn't fit anywhere else... » Archive through August 15, 2003 » webMethods Ezine: Float and Double: 1/3 + 2/3 = 0.99999999

Author Message
Dan Green

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, October 02, 2002 - 09:45 pm:   Print Post

Questions or comments about this webMethods Ezine article?

Click here to read the original text.
Rob Eamon (reamon)
Posted on Monday, May 05, 2003 - 05:16 pm:   Print Post

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:   Print Post

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.

 

 

Add Your Message Here
Post:
Username: wMUsers Members: Use your username/password to increase your "Total Posts" ranking and link your profile.

Non-members: Use your full name as a username.
Password:
Email:
Options: Enable HTML code in message
Automatically activate URLs in message
Action:


Advertise at wMUsers

Check out our Frappr!




© All Rights Reserved, 2001-2005.

Script Execution Error

Your discus.conf file could not be opened.
Error:  Open discus.conf: No such file or directory
Script: dummy.cgi
OS:     linux
Perl:   5.008008
Descr:  No such file or directory
Discus: 4.0

Read documentation in the Support Center
Also try your Program Diagnostics