- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- adding 2 large integer numbers on ia64 gives negat...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2009 02:53 PM
тАО04-24-2009 02:53 PM
While adding two large integer numbers using expr command we discovered that the outcome becomes negative. (Small numbers are fine).
This happened on ALL our HP-UX ia64 servers.
Any idea?
Thank you in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2009 03:26 PM
тАО04-24-2009 03:26 PM
SolutionThis is due to 32-bit arithmetic. Use 'bc' or 'adb' or 'awk' or 'perl' to perform your arithmetic. The 'ksh' shell at 11.23 will do 64-bit arithmetic too.
Y=2147483647
# X=$(expr $Y + 1);echo $Xecho
-2147483648
# echo $Y|awk '{printf "%10.0f\n",$0+1}'
2147483648
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2009 04:13 PM
тАО04-24-2009 04:13 PM
Re: adding 2 large integer numbers on ia64 gives negative results
No, this is due to _signed_ arithmetic. The
number of bits merely determines what "large"
is.
When I was young, learning about computers
involved learning how computers count. (That
was back when computers were used mostly for
computation. It's been a while.) I gather
that this is less common now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2009 04:21 AM
тАО04-27-2009 04:21 AM
Re: adding 2 large integer numbers on ia64 gives negative results
$ echo $((17179869184+17179869184))
0
$ echo "17179869184+17179869184"|bc
34359738368
My 2 cents,
Armin
PS: Please assign points if you find answers useful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2009 07:12 AM
тАО04-27-2009 07:12 AM