- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- handling 12 digit number
Operating System - HP-UX
1748223
Members
4876
Online
108759
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО05-25-2001 12:17 AM
тАО05-25-2001 12:17 AM
handling 12 digit number
Hi
I need to compare 12+ digits number in a shell script, but when i do normal comparison using -lt or -gt, I am not getting the correct result.
I am working on K380, using 64bit kernel
How to get around this problem
Thanks in advance
Praveen
I need to compare 12+ digits number in a shell script, but when i do normal comparison using -lt or -gt, I am not getting the correct result.
I am working on K380, using 64bit kernel
How to get around this problem
Thanks in advance
Praveen
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2001 07:00 AM
тАО05-25-2001 07:00 AM
Re: handling 12 digit number
Hi Praveen,
with such long numbers, you have to convert to strings. I attached a SIMPLE c-program, doing it. It does not validate parameters, esp. length, just fills in leading zeros and does a string compare.
Sample compilation on HP-UX 11.0 included.
Since '-' is smaller than '0', it even works with negative numbers. It does not work with decimals, you might need to adjust it, if this is needed !!! Currently it is for a max of 29 digits, but you can modify it as you like.
Volker
with such long numbers, you have to convert to strings. I attached a SIMPLE c-program, doing it. It does not validate parameters, esp. length, just fills in leading zeros and does a string compare.
Sample compilation on HP-UX 11.0 included.
Since '-' is smaller than '0', it even works with negative numbers. It does not work with decimals, you might need to adjust it, if this is needed !!! Currently it is for a max of 29 digits, but you can modify it as you like.
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2001 07:17 AM
тАО05-25-2001 07:17 AM
Re: handling 12 digit number
Hi,
The following attachment will do the trick. It uses bc (binary calculator) to do unlimited precision comparisons.
Use it like this:
MYVAR=`bc.sh ${N1} ${N2}`
where N1 and N2 are the comparands
if N1 < N2, MYVAR will be set to -1
if N2 = N2, MYVAR will be set to 0
if N1 > N2, MYVAR will be set to 1
You can then use the value of MYVAR within your typical shell logic.
Regards, Clay
The following attachment will do the trick. It uses bc (binary calculator) to do unlimited precision comparisons.
Use it like this:
MYVAR=`bc.sh ${N1} ${N2}`
where N1 and N2 are the comparands
if N1 < N2, MYVAR will be set to -1
if N2 = N2, MYVAR will be set to 0
if N1 > N2, MYVAR will be set to 1
You can then use the value of MYVAR within your typical shell logic.
Regards, Clay
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2001 07:19 AM
тАО05-25-2001 07:19 AM
Re: handling 12 digit number
Ooops, Remove the cp ${B1} /tmp/x.bc line from the attachment, it was there for testing.
Clay
Clay
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP