ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Subtracting or adding two decimal

Post new topic  Reply to topic
 Subtracting or adding two decimal « View previous topic :: View next topic » 
Author Message
Missam
PostPosted: Fri Feb 27, 2004 1:53 pm    Post subject: Subtracting or adding two decimal Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

Hai i have a requirement where i need to add or subtract two fields which i generated in output tree few lines of code above,And my output tree is XML
my code looks like this
Set outptr.Field1 = inptr.Field1 ; ---- Value for this is 31330.10
Set outptr.Field2 = inptr.Field2;-----Value for this is 1.2

Set outptr.Field1 = CAST(outptr.Field1 As Decimal) - CAST(outptr.Field2 As Decimal)

i'm seeing the output like this 031331.3
i don't understand why i'm seeing extra 0 infront of the value
Back to top
View user's profile Send private message
EddieA
PostPosted: Fri Feb 27, 2004 2:27 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Wow. 31330.10 - 1.2 = 31331.3.

Are you running this on a Pentium.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
Missam
PostPosted: Fri Feb 27, 2004 2:41 pm    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

Hey Come On ,
I'm not concerned about adding or subtracting,i'm concerned on the extra 0 infront,which i don't want.Any way i got a solution for this
i casted those two fields to floats first and casted the whole thing as decimal to get rid of 0.
Back to top
View user's profile Send private message
mgk
PostPosted: Sun Feb 29, 2004 9:36 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

The leading ZERO present in certain DECIMAL operations has been removed in V5, along with a several other fixes for decimal handling. This fix is NOT available on previous versions of the product as is was a large change, (rewrite) of the decimal handling code.


Cheers,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
Carl_P
PostPosted: Tue Jul 27, 2004 3:19 am    Post subject: Reply with quote

Novice

Joined: 15 Apr 2003
Posts: 11

I too have run into the leading zero issue. This causesme an issue when looping through an XML structure accumulating values. After several loops (and while the value is actually very small) an overflow error is encountered. I tried using a FLOAT to counter this but then I ran into precision problems. How would you recomend I code this looping behaviour?

I'm running WMQI v2.1 on Windows 2k.

Thanks,
Carl
Back to top
View user's profile Send private message
Ramphart
PostPosted: Tue Jul 27, 2004 4:11 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2004
Posts: 150
Location: South Africa, JHB

Carl_P wrote:
I too have run into the leading zero issue. This causesme an issue when looping through an XML structure accumulating values. After several loops (and while the value is actually very small) an overflow error is encountered. I tried using a FLOAT to counter this but then I ran into precision problems. How would you recomend I code this looping behaviour?
Carl



The overflow is not due to the leading 0's. It's the way decimals are handled (or the lack of handling) in WMQI 2.1.

I found that it's a bug and it just won't work if the number of repeating elements goes beyond a certain depth. Can't remember how many. 29 element repeats or something. In my case I've done the following:

Declare varFloat FLOAT;
Set varFloat = (SELECT SUM( CAST(R.Value AS FLOAT) )
FROM InputBody.Invoice.InvoiceLineList.WIDET[] AS R);

Do the same with a decimal and it WON'T work on WMQI 2.1 if the no of elements is greater than 29 or so.

_________________
Applications Architect
Back to top
View user's profile Send private message
Carl_P
PostPosted: Wed Jul 28, 2004 3:50 am    Post subject: Reply with quote

Novice

Joined: 15 Apr 2003
Posts: 11

Thanks Ramphart - is there no work around to the decimal bug? As I said in my previous post floats give me a precision issue so I'm not really able to use these.

At present I'm tied to WMQI v2.1
Back to top
View user's profile Send private message
Ramphart
PostPosted: Mon Aug 16, 2004 4:45 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2004
Posts: 150
Location: South Africa, JHB

Honestly, I dont know (and dont think so) if there's a work around for this.
_________________
Applications Architect
Back to top
View user's profile Send private message
Missam
PostPosted: Mon Aug 16, 2004 5:54 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

Hi Ramphart
If you want a work around to this you can do this.First Convert all numbers to FLoat and then Convert back to decimal after calculation.
Like This

Set outptr.Field1 = CAST(CAST(outptr.Field1 As Float) - CAST(outptr.Field2 As Float) AS DECIMAL)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Subtracting or adding two decimal
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.