- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- convert hexa to decimal values
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-06-2007 01:01 AM
тАО04-06-2007 01:01 AM
i'm trying to convert an hexadicimal value to decimal but it seems impossible with my knowledge. ;)
that's what i tried (under ksh).
HPUX B.11.00:
# echo 0xfffff000=D |adb
-4096
# printf "%d\n" 0xfffff000
printf: Error converting 0xfffff000
2147483647
# print - $((16#fffff000))
-4096
# echo "obase=86 0xfffff000" |bc -l
syntax error on line 1, /usr/lib/lib.b
# echo "obase=86 ; fffff000" |bc
syntax error on line 1
# echo "fffff000" |tr "[[:xdigit:]]" "[[:digit:]]"
tr: String2 contains an invalid character class.
i've the same errors in HP-UX B.11.11/B.11.23
i need to convert these values for a script so, do you have advice for it ?
Regards,
Cedrick Gaillard
Solved! Go to Solution.
- Tags:
- hex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 01:12 AM
тАО04-06-2007 01:12 AM
Re: convert hexa to decimal values
$ typeset -i10 x=16#fffff000; echo $x
(This returns an unsigned int for 11.23 and 11.31 ksh. sh returns -4096.)
What was wrong with your adb and $(( )) solutions?
- Tags:
- typeset
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 01:13 AM
тАО04-06-2007 01:13 AM
Re: convert hexa to decimal values
There's nothing wrong with your methodology, only that your numbers exceed 32-bit integers.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 01:48 AM
тАО04-06-2007 01:48 AM
Re: convert hexa to decimal values
i know now that this is because my numbers exceed 32-bit integers.
do you have a solution for convert these values correctly ?
my system is 64bits, is there a 64bit binary who can calculate the result?
the result of 0xfffff000 would be 4294963200, not -4096
and why
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 01:58 AM
тАО04-06-2007 01:58 AM
Re: convert hexa to decimal values
$ echo "4294963200*1234.234"|bc
5300989610188.800
Bill Hassell, sysadmin
- Tags:
- bc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 02:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 02:10 AM
тАО04-06-2007 02:10 AM
Re: convert hexa to decimal values
as indicated behind, i've tried bc, maybe with a wrong syntax:
# echo "obase=86 ; fffff000/1024/1024" |bc
syntax error on line 1,
i've just looking something, at home i've a linux, it have a 32bit processor however, it can convert without problem so, where is the limitation ?
$> uname -s ; printf "%d\n" 0xfffff000
Linux
4294963200
# uname -s ; printf "%d\n" 0xfffff000
HP-UX
printf: Error converting 0xfffff000
2147483647
Regards,
Cedrick Gaillard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 02:27 AM
тАО04-06-2007 02:27 AM
Re: convert hexa to decimal values
Use UPPERCASE hexadecimal digits with 'bc' as I showed above.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 02:29 AM
тАО04-06-2007 02:29 AM
Re: convert hexa to decimal values
the uppercase letter give me no errors from bc now and correct my [io]base variables has gived to me a good result.
problem is solved, thanks ;)
Regards,
Cedrick Gaillard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2007 12:17 PM
тАО04-06-2007 12:17 PM
Re: convert hexa to decimal values
Does it handle arbitrary 64 bit numbers? Like the 11.23 ksh?
I guess it depends on the standard and whether it is worth it to extend it to long longs.