简体   繁体   中英

NUMIN producing wrong output,how to get right answer?

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]

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 ); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM