1752422 Members
5943 Online
108788 Solutions
New Discussion юеВ

Re: How to Read Hex?

 
SOLVED
Go to solution
Josh_13
Super Advisor

Re: How to Read Hex?

most simplistic thing i can think of is to use javascript.

####.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>

Josh_13
Super Advisor

Re: How to Read Hex?

define irony:

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.)
Eric Ladner
Trusted Contributor

Re: How to Read Hex?

The printf fails in ksh because the number is larger than the interal representation of %d.

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..

someone_4
Honored Contributor

Re: How to Read Hex?

I understand !! whoo hooo !!!
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
Patrick Wallek
Honored Contributor

Re: How to Read Hex?

You are getting a bit 0 happy when typing Richard.

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)
someone_4
Honored Contributor

Re: How to Read Hex?

Ha ha ..
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
harry d brown jr
Honored Contributor

Re: How to Read Hex?

Richard,

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
Live Free or Die
someone_4
Honored Contributor

Re: How to Read Hex?

Hex is just too much fun =)
Would anyone happened to know how they get theese numbers from hex to decimal and back. Is there an acutal math formula?

Richard
Patrick Wallek
Honored Contributor

Re: How to Read Hex?

Just take Harr's response and expand on it:


# * (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?
Eric Ladner
Trusted Contributor

Re: How to Read Hex?

Just a personal view..

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.