expr: Integer argument too large

Hi all,

In KSH, I have got an error message like,
"expr: Integer argument too large"
I received this error message when I mutiply two large values and displaying the resultant output.

Is there any other altenative way to go with too large values?

Kindly let me know asap...

Thanks in advance!!!

Geetha

Any suggestions please...

Version of unix and size of the numbers would help.

Try "bc" which is a front end to "dc".

result=`echo "1048576 * 1048576"|bc`

echo $result
1099511627776

Okie... Lemme check and come back... Thanks dude...

Sorry boss... I'm not getting...
Here is my code...
value=`expr $size \* 1152921504606846976`

Ur valuable suggestions please!!!

try this it worked for me:

[code]
c=`expr 1048576 \* 1048576`
$ echo $c
1099511627776
[\code]

i am using bash shell.

this worked as well:

$ size=1048576
c=`expr $size \* 1048576`

$ echo $c
1099511627776

You seem to be multiplying by 1024 to the power of 6.

echo "1024 ^ 6"|bc
1152921504606846976

To multiply by 1024 to the power of 6 for example:

size=1000000
echo "$size * (1024 ^ 6)"|bc
1152921504606846976000000

Have you considered working in more manageable units?

try this!!! :b:

echo "$size  * 1152921504606846976"|bc

Thank u all

But I have a qn here... I need to assign that value to a variable. Could u please help me???

I tried in so many ways... but couldnt find the exact way...

?????????

Any other suggestions please...

Please don't bump up questions, that against the rules.

Regards

It is possible that your script has defined the variable "value" as an integer (typeset -i value). The shell integer variables cannot hold very large numbers. Just hold them in a character field. Also, most versions of "expr" cannot deal with very large numbers.

To ensure that your variable "value" is a character variable "unset" it.

size=1000000
unset value
value=`echo "$size * (1024 ^ 6)"|bc`
echo $value
1152921504606846976000000