- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to Read Hex?
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
Forums
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
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
тАО02-27-2002 10:05 AM
тАО02-27-2002 10:05 AM
Richard
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 10:11 AM
тАО02-27-2002 10:11 AM
Re: How to Read Hex?
echo 8000000 | awk '
{
hexstr="0123456789abcdef"
newnum=tolower($1)
slen = length(newnum)
decnum = 0
for (i=1; i < slen+1;i++)
{
tpos = index(hexstr,substr(newnum,i,1)) - 1
decnum = decnum + ( (16 ** (slen -i)) * tpos)
}
printf("%s is %d\n",newnum,decnum)
} '
#
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 10:15 AM
тАО02-27-2002 10:15 AM
Re: How to Read Hex?
Of course, if you have a M$/puke machine, it's calculator has a HEX to DEC conversion.
And better yet,
/usr/dt/bin/dtcalcin/dtcalc
has a HEX option!
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 10:19 AM
тАО02-27-2002 10:19 AM
Re: How to Read Hex?
200MB = 200 x 1024 x 1024 = 209715200 bytes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 10:25 AM
тАО02-27-2002 10:25 AM
Re: How to Read Hex?
So right now I have 67108864 b = 65.536 MB ?
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 10:26 AM
тАО02-27-2002 10:26 AM
Re: How to Read Hex?
You can also do this at commandline:
# printf "%d\n" 0xfff
...which would return decimal 4095...and inversely:
# printf "%x\n" 4095
...which returns 0xfff
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 10:27 AM
тАО02-27-2002 10:27 AM
Re: How to Read Hex?
looks like this:
8 * 16,777,216 (# * (16^6))
0 * _10,48,576 (# * (16^5))
0 * ____65,536 (# * (16^4))
0 * _____4,096 (# * (16^3))
0 * _______256 (# * (16^2))
0 * ________16 (# * (16^1))
0 * _________1 (# * (16^0)) -- remember 16^0 = 1
--------------
== 134,217,728
And yes, 0x4000000 = 67,108,864 bytes = 64MB (64 * 1024 * 1024)
l;ive free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 10:31 AM
тАО02-27-2002 10:31 AM
SolutionTo convert from decimal to hex (we are setting the output base 16, leaving input at 10):
$ bc -l
obase=16
256*1024*1024
10000000
255
FF
quit
To convert hex numbers to decimal (we are setting the input base to base 16, leaving the output base at 10)
$ bc -l
ibase=16
FF
255
40000000
1073741824
FFFF
65535
quit
Note that the hex numbers entered MUST be in upper case to work, otherwise you will get syntax errors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 10:31 AM
тАО02-27-2002 10:31 AM
Re: How to Read Hex?
printf: Error converting 0xc8000000
2147483647
printf "%x\n" 200 c8
printf "%d\n" 0xc8 200
what about the last 000000? Do they not count?
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 10:40 AM
тАО02-27-2002 10:40 AM
Re: How to Read Hex?
I suspect you are in the k-shell when doing the printf and getting the error. Switch to the posix shell (/usr/bin/sh or /sbin/sh) and you won't have a problem.
And YES, the 0's at the end DEFINITELY DO MATTER. Chopping the 0's off of the end of the hex # would be about like chopping the last 5 zeros off of 1000000. 10 != 1000000 and 0xc8 != 0xc8000000
0xc8 = 200
0xc8000000=2,147,483,647 = 2GB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 11:20 AM
тАО02-27-2002 11:20 AM
Re: How to Read Hex?
####.toString(10)
where #### is the hex number
here's a quickly written html page to use. double check that i have it right before using it. you might have to alert toString that the number is NOT base 10.
<script language=javascript>
function convert(){
var hexnum=(document.todec.hex.value);
document.todec.dec.value=(hex.toString(10));
};}
</script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 11:36 AM
тАО02-27-2002 11:36 AM
Re: How to Read Hex?
taking a minute to write what i wrote before, then coming across this thread, http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x077350011d20d6118ff40090279cd0f9,00.html when searching for the success thread to add my latest one to that.
(n/a for this. it was dumb luck that i found the thread.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 12:18 PM
тАО02-27-2002 12:18 PM
Re: How to Read Hex?
Come on guys! Use the 'bc' command.. it doesn't get any simpler than that.
bc successfully printed this out:
$ bc
ibase=16
C00000000000000000000000000000000000
16725558898897967356151788704486271129485312
That's a rather large number. It'll go much larger, but then it'd wrap and look nasty..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 12:35 PM
тАО02-27-2002 12:35 PM
Re: How to Read Hex?
hex is 16 based !
so here we go ..
0x4000000 = 67,108,864 bytes = 64MB (64 * 1024 * 1024)
If I want 200MB
200MB=(200*1024*1024)= 209715200 bytes = C8000000
c8000000 is not = 2,147,483,647 = or 2GB
the hex covert says
2,147,483,647 B = 7FFFFFFF in hex
and
c8000000 = 3355443200 bytes = 3200 mb = 3 GB
It looks like the hex calc and bc are always form bytes to hex .right?
So using the hex coverter
0x4000000 = 64 MB
and I am wanting to bump it up to 200MB
so I would use
0xc8000000
or more simple for 128MB
0x8000000
Here it all is using the bc.
#bc -l
ibase=16
C8000000
3355443200
8000000
134217728
C8000000
3355443200
4000000
67108864
8000000
134217728
#bc -l
obase
10
obase=16
256*1024*1024
10000000
2147183647
7FFB6C1F
67108846
3FFFFEE
67108864846
FA000034E
67108864
4000000
3355443200
C8000000
134217728
8000000
quit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 12:44 PM
тАО02-27-2002 12:44 PM
Re: How to Read Hex?
200 MB = c800000 (only 5 zero's)
2GB = 80000000 (7 zero's)
3.125 GB = c8000000 (6 zero's)
Make VERY sure you type the correct # of zero's. They are VERY significant. (The difference between hundreds, thousands, millions, billions)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 12:48 PM
тАО02-27-2002 12:48 PM
Re: How to Read Hex?
I just caught that my self and was doing that math ..
(NET-lupus) /# bc -l
ibase=16
C8000000
3355443200
7FFFFFFF
2147483647
quit
(NET-lupus) /# bc -l
obase=16
256*1024*1024
10000000
209715200
C800000
3355443200
C8000000
You are very right though =)
I have to watch that ..
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 12:57 PM
тАО02-27-2002 12:57 PM
Re: How to Read Hex?
c8000000 is not = 2,147,483,647 = or 2GB
is correct, because C8000000 is 200MB (200 * 1024 * 1024), whereas 2GB is (2 * 1024 * 1024 * 1024) = 2147483648 = 0x80000000.
and 256MB is (256 * 1024 * 1024) = 268435456 = 0x10000000
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 01:05 PM
тАО02-27-2002 01:05 PM
Re: How to Read Hex?
Would anyone happened to know how they get theese numbers from hex to decimal and back. Is there an acutal math formula?
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 01:20 PM
тАО02-27-2002 01:20 PM
Re: How to Read Hex?
# * (16^16)= ???
# * (16^15)= ???
# * (16^14)= ???
# * (16^13)= ???
# * (16^12)= ???
# * (16^11)= ???
# * (16^10)= ???
# * (16^9)= ???
# * (16^8)= ???
# * (16^7)= ???
# * (16^6)= ???
# * (16^5)= ???
# * (16^4)= ???
# * (16^3)= ???
# * (16^2)= ???
# * (16^1)= ???
# * (16^0)= ??? - remember 16^0 = 1
and then add them all together to get your value. There really is no other magic formula.
In hex the "number" range from 0-9 then a-f. So if you were counting it would be:
0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,10,11,12
where a=10, b=11, c=12, d=13, e=14, f=15.
So lets convert a hex to decimal:
fba563
f = 15 = 15 * (16^5) = 15 * 1048576 = 15728640
b = 11 = 11 * (16^4) = 11 * 65546 = 720,896
a = 10 = 10 * (16^3) = 10 * 4096 = 40960
5 = 5 * (16^2) = 5 * 256 = 1280
6 = 6 * (16^1) = 6 * 16 = 96
3 = 3 * (16^0) = 3 * 1 = 3
Now add up 15,728,640 + 720,896 + 40,960 + 1,280 + 96 + 3 = 16,491,875
You basically start with the last digit and multiply it by 16^0 (16 to the power of 0) and work your way back to the left incrementing the power by 1 each time (16^1, 16^2, etc.)
Understand?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 01:27 PM
тАО02-27-2002 01:27 PM
Re: How to Read Hex?
I'd use 256MB for maxdsiz instead of an 'odd' number (that's 10000000 in hex, or a 1 with 7 zeros).
Call me funny, but I like to keep the kernel params nice round numbers, especially when dealing with memory.
Also, there's nothgin wrong (that I can tell) of setting maxdsiz to the amount of physical memory on the box.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2002 01:32 PM
тАО02-27-2002 01:32 PM