1846823 Members
11641 Online
110256 Solutions
New Discussion

Re: Max integer value

 
SOLVED
Go to solution
Kellogg Unix Team
Trusted Contributor

Max integer value

I've HP-UX 11.00 (64 bit) on an N-class. When I'm doing arithmatic on an integer variable in 'ksh' shell script, I get negative values when it is more than 2 power 31. It looks like the default size of integer variable is 32-bit. Does anyone know if this can be changed to 64-bit, either by changing some kernel parameter or within the shell script by some type definition.

Thanks,
Srinivas Emani
work is fun ! (my manager is standing behind me!!)
2 REPLIES 2
Paul Hite
Trusted Contributor
Solution

Re: Max integer value

There is no way to induce ksh to use 64 bits. Sorry for the bad news.

To do arithmetic in ksh with no magnitude limit, you can use bc. Instead of:

((a=b+c))

do:

a=$(echo $b + $c | bc)

But a,b, and c must NOT be typeset to integers to do this.
CHRIS_ANORUO
Honored Contributor

Re: Max integer value

Hi,

You can also use bc -l for decimals
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.