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 » Need Guidance in the EVAL rounding to the nereast interger

Post new topic  Reply to topic
 Need Guidance in the EVAL rounding to the nereast interger « View previous topic :: View next topic » 
Author Message
bharu
PostPosted: Thu Nov 30, 2017 10:40 am    Post subject: Need Guidance in the EVAL rounding to the nereast interger Reply with quote

Newbie

Joined: 16 Jul 2012
Posts: 9

Hi

I am trying to do the EVAL statement . But all the decimal value get rounded to the nearest integer value example ( value is -1.88 means its returning the value as -2). I don't want to pass the round value because it's the amount calculation.
I am not able to perform this using mathematical calculation also its completely the run time calculation.

Here i am receiving the value from other portal so they will be sending the row.col to row.coln and its not going to perform the same calculation always . it may be addition,sub,Division combination of all.

rRow.Col1 its treating as char tried with explicit casting also CAST(rRow.Col1 as decimal) that also not helping.

Example below :
---------------

Input :
(col19 * col14) + (col24 /col14 - Col19 + 10)* col19 + 20

we need to interrupt as
(rRow.col19 * rRow.col14) + (rRow.col24 /rRow.col14 - rRow.Col19 + {10})* rRow.col19 + {20}

Here rRow.col19 is going to have some value
rRow.col19 = 100
rRow.col14 = 200
rRow.col24 = 70.6

(100 * 200) + (70.6 /200 - 100 + 10)* 100 + 20 = 11055.3

return result is 11055

CODE snippet :
---------------
DECLARE dResult1,dResult2 DECIMAL 0.0;
DECLARE cDecimal,cResult,cTemp,d1 CHARACTER;
SET Environment.Variables.Col1 = '100';
SET Environment.Variables.Col2 = '7800';
SET Environment.Variables.Col3 = '12';
SET Environment.Variables.Col4 = '10';
SET Environment.Variables.Col5 = '9';
DECLARE rRow REFERENCE TO Environment.Variables;
SET cDecimal = (rRow.Col1 / rRow.Col2 - rRow.Col4 + rRow.Col3);
SET cDecimal = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(cDecimal,'(','''(''||'),'+','||''+''||'),'*','||''*''||'),'/','||''/''||'),')','||'')'''),'-','||''-''||');
SET dResult1 = EVAL(cDecimal) ;
SET dResult = CAST(EVAL(cResult) AS DECIMAL CCSID 1208);

(col24 /coL14 - Col19 + 10)
100/7800 -12+10 = actual value expected -1.98 but EVAL returned -2.

Please let us know if you need any more details
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 30, 2017 10:50 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

If I had to build an evaluation engine, I can think of a number of platforms I'd use before I used IIB. Even if I had to get IIB to call out to it because I wanted IIB's transport support.

This is just contact admin, and will be a ***** to troubleshoot in production.

I suspect your problem is that you're mixing integer values and decimals, so at some point in this insanity something's being cast. Try expressing 10 as 10.0 so it's a decimal not an integer and see what happens.

Better still, try something else entirely on a different platform.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
bharu
PostPosted: Thu Nov 30, 2017 11:18 am    Post subject: Reply with quote

Newbie

Joined: 16 Jul 2012
Posts: 9

Hi Vic,
Thanks for the response . Here the constraint is we don't know what value we are going to receive from the input. In this case everything is dynamic from the client .

Eg :
(78+28/90) *(78-26+89/90)

so we need to look up the col value and get the value and do the calculations.

(Row.col24+28/Row.col15)*(Row.col24-rRow.col2 +Row.col20 ) / 9

Row is the construction of the input file. so we cant convert all row values to decimal or int.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 30, 2017 11:49 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

bharu wrote:
Row is the construction of the input file. so we cant convert all row values to decimal or int.


But you could express them all as decimals.

bharu wrote:
Here the constraint is we don't know what value we are going to receive from the input. In this case everything is dynamic from the client


I stand by my previous comments surrounding this ghastliness and the lack of suitability IIB brings to it.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
bharu
PostPosted: Thu Nov 30, 2017 12:18 pm    Post subject: Reply with quote

Newbie

Joined: 16 Jul 2012
Posts: 9

How could the input file have character right .


You don't know which col you need to convert as decimal.

(Row.col24+28/Row.col15)*(Row.col24-rRow.col2 +Row.col20 ) / 9

expression will be evaluated and the row.col value will be picked dynamically like xml fieldname field value .
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 30, 2017 12:44 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

bharu wrote:
You don't know which col you need to convert as decimal.


So you do them all as decimal.

bharu wrote:
expression will be evaluated and the row.col value will be picked dynamically like xml fieldname field value .


Again, I assert that this is a horrible design implemented on the wrong platform. You think you're having problems now, wait until you start running production data through it.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Dec 01, 2017 5:58 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Why restrict yourself to decimal?
Cast each of the row values as float, declare the result as a float, do the calculations on the float values.
Finally cast the result as whatever you want with whatever format you need.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Need Guidance in the EVAL rounding to the nereast interger
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.