Reputation: 15
I am creating a program to count number of digits in number
When I am putting value in 5 digits it is producing right answer but when I put value in 6 digits it is producing wrong value.
To see what happening in the code I debugged the code and found that when I put 5 digit number,it convert from string to int correctly but when I put 6 digit value it convert the value wrong and give some negetive value.
I am using
CALL NUMIN(AB,NUM,10,STAT);
AB is a string ab[0:40]
NUM is an Integer
STAT is a string STAT[0:50]
Upvotes: 1
Views: 33
Reputation: 111
In TAL the Unsigned Integer ranges from 0 to 65,535 and Signed Integer ranges from -32,768 to 32,767 , so it is not possible to get 6 digit input in to the string and convert it using NUMIN GPC(Guardian procedure call).
Instead you can use signed double word integer INT(32) .EXT which is 32-bit integer in range -2,147,483,648 to 2,147,483,647 in which you can easily use 6 digit or more than 6 digit inputs . To convert 6 character or more than 6 character string to Integer use DNUMIN GPC
DNUMIN ( ascii-num
,signed-result
,base
,status );
Upvotes: 0