What's the max integer a variable can hold?

I would like to know the maximum integer that a variable can hold. Actually one of my variable holds value 2231599773 and hence the script fails to process it.Do we have any other data type or options available to handle this long integers?

As long as you do not attempt arithmetic operations, a string of numbers can be huge.
Shell arithmetic is limited to signed long 32 bit - +/- 2147483648

awk does double arithmetic - DBL_MAX DBL_MIN in limits.h, usually 15 digits of precision

bc can deal with up to 20 digits of precision.

Thanks.
But when i run the below script im able to process values which are longer than the 32 bit value.Pls advise.

D=12345678912332232
echo $D
let DD=$D*20
echo DD id $DD
if [[ $DD -gt 0 ]]
then
  echo PASS  # prints PASS successfully as it intend to be.
else
  echo FAILLLLLLLL
fi

You did run the script didn't you.

I get the following output:

12345678912332232
DD id 1503437728
PASS

The number in variable $DD is clearly corrupted during the arithmetic operation. This is because of binary overflow.
The largest positive number you can hold in a shell integer variable is:
+2147483647 .
-which is exactly one less than (1024 x 1024 x 1024 x 2).

To work in Shell with larger numbers you must use and external program such as "bc" and store intermediate numbers in text variables.

ANSWER=""
ANSWER=`echo "12345678912332232 * 20" | bc`
echo "${ANSWER}"

246913578246644640

oh!! I get the output as below. im using ksh.

12345678912332232
DD id 246913578246644640
PASS

Are you by any chance on a modern 64-bit Operating System with ksh93 ?

ksh93 on 32-bit Vista SUA

#!/bin/ksh93

integer D=12345678912332232
printf "%ld %ld\n" $D $D*20

gives

$ ./test
12345678912332232 246913578246644640

Lost the plot here. What is the failure referred to in post #1 ?

You have not told us what shell or other scripting utility this problem applies to. It is difficult to provide an appropriate answer without this basic information.

Im using ksh. And im not sure how to find whether my pc is 32 or 64 bit.
Can someone help..?