Value truncating after multiplication



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Value truncating after multiplication

Postby shankar_dh » Sat Mar 29, 2014 2:09 am

Hi,

I am multiplying below 2 variables
Var1 --> 8,16,PD
Var2 --> 29,15,ZD [Its 9(5)v9(10)]
Below is the input file
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
IDPBBD    b  b b b %     000010000000000031714                       
CCDCCC0023862286283862600000FFFFFFFFFFFFFFFFFFFFF44444444444444444444444
9472240470223322320223C0000100001000000000003171400000000000000000000000
-----------------------------------------------------------------------


After multiplication below is the output file,Multiplied value starts from position 39
----+----1----+----2----+----3----+----4----+----5----+----6----+----
***************************** Top of Data ***************************
IDPBBD    b  b b b %0000100000000002323826223823082622360000000000
CCDCCC00238622862838626FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
9472240470223322320223C0000100000000002323826223823082622360000000000


Expected output +4,273,082,622,323,826,223,823,082,622.36 X 1.0000000000 = +4,273,082,622,323,826,223,823,082,622.36
What I am getting ------------>> +2,323,826,223,823,082,622.36

SORT card I have used,
SORT FIELDS=COPY                                                     
OUTREC IFTHEN=(WHEN=INIT,                                           
BUILD=(1:1,23,24:29,15,39:(8,16,PD,MUL,29,15,ZD),72:25,4,195:36,6)) 


Please let me know how to avoid this truncation.
shankar_dh
 
Posts: 41
Joined: Fri Mar 22, 2013 1:00 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Value truncating after multiplication

 

Re: Value truncating after multiplication

Postby BillyBoyo » Sat Mar 29, 2014 3:38 am

You have a 30-digit number. You shifted it left 10 digits. It can be a maximum of 31 digits. So you lost the leading nine digits.

Why do you have such a huge value?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Value truncating after multiplication

Postby shankar_dh » Sat Mar 29, 2014 9:40 am

Thanks Billy for the reply. This is the value of sum of account numbers, Account numbers might be millions. So, what if I get such a huge value in production.
It should be a problem.
Is there anyway to avoid it??
shankar_dh
 
Posts: 41
Joined: Fri Mar 22, 2013 1:00 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Value truncating after multiplication

Postby dick scherrer » Sat Mar 29, 2014 9:30 pm

Hello,

Why does someone believe it is a good idea to do arithmetic on account numbers?

Sounds like a design issue . . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Value truncating after multiplication

Postby enrico-sorichetti » Sat Mar 29, 2014 10:18 pm

Account numbers might be millions. So, what if I get such a huge value in production.

You will be out of luck :mrgreen:

the 31 decimal digits is somehow carved in stone
the problem should have been spotted when designing the application !
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Value truncating after multiplication

Postby BillyBoyo » Sun Mar 30, 2014 5:51 am

Summed account numbers? I don't think so. How do you get 0.36 of an account number? You have a value which would allow for about a billion 20-digit account numbers, ignorigin the decimals. That's too many account, with too many digits.

Nope, doesn't make sense, There is more in there than account numbers.

What are you multipling them by, and why?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Value truncating after multiplication

Postby NicC » Sun Mar 30, 2014 1:31 pm

Perhaps what he means is "account balances" but, unless the company is planning to take over all the accounts in the world I somehow do not think he will need a field that big!
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Value truncating after multiplication

Postby enrico-sorichetti » Sun Mar 30, 2014 1:50 pm

we might have hit a terminology barrier.
in italian banking jargon the numbers are the balance times the number of days
and it is used when computing the interests

wonder if it is something like that?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Value truncating after multiplication

Postby shankar_dh » Sun Mar 30, 2014 6:20 pm

Hi Everyone..

Thanks for all your reply,
Yes, Nic is correct. I meant Account balance.
Yes, I know 31 digits is a huge number. We wont be getting such a huge balance but our design should be in a position to handle it , so I was thinking in that line.
Now, I have replace SORT with SAS just for the multiplication. Rounding is a big problem is SORT, I wish we had a function to round a value like in COBOL ROUNDING.

Regards,
Shankar.
shankar_dh
 
Posts: 41
Joined: Fri Mar 22, 2013 1:00 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Value truncating after multiplication

Postby BillyBoyo » Mon Mar 31, 2014 4:19 am

You haven't said what that multiplier is and why you need it. What are the valid ranges for it? In algebra, dividing by the inverse is the same as multiplication. Depending on the range of that 9(5)V9(10) you may be able to divide. You could try dividing that number by one, which is the same as multiplying by one, but without requiring 46 digits, but the magnitude of your value could still require more than 31 digits, so again you'd get truncation.

I'm surprised SAS can deal with 46 digits in an intermediate value with multiplication, but if it does, it does.

Rounding is not a problem for SORT, it just rounds down. What you mean is you want a different rounding. What rounding do you want, specifically.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post