Page 1 of 1

How to do simple Maths with Hex?

Posted: Mon Jan 21, 2008 2:55 pm
by mikeeeeeeey
Hi guys,

How would I do compare two Hex numbers to find their difference?

I've tried hexdec() and then adding/subtracting but some of these numbers vastly differ, and simply doing $hex_number - $hex_number2 always returns 0.

Anyone know anything about this?

Thanks in advance

Re: How to do simple Maths with Hex?

Posted: Mon Jan 21, 2008 4:11 pm
by Christopher
You could use base_convert(), or maybe try something like:

Code: Select all

"0x$hex_number" - "0x$hex_number2"

Re: How to do simple Maths with Hex?

Posted: Tue Jan 22, 2008 12:03 am
by Kieran Huggins
base_convert() FTW!