[thelist] hexidecimal in asp
Johnson, Christopher (MTO)
Christopher.Johnson at mto.gov.on.ca
Tue Jun 1 08:57:12 CDT 2004
-----Original Message-----
From: Ken Schaefer
There is also a very efficient formula for converting hex -> decimal that a
maths major once gave me - I'll need to dig it out though, if you do need
the final result in decimal.
If you can parse the number into its different components, the easy way of
converting is simply to insert the values into the following formula:
(i*n)*16^n + ... + (n+4)*16^4 + (n+3)*16^3 + (n+2)*16^2 + (n+1)*16^1 +
(n+0)*16^0
where n = the decimal value of the digit at the n+i position. Here is an
example
in hex: F64A would be
15*16^3 + 6*16^2 + 4*16^1 + 10*16^0
= 61440 + 1536 + 64 + 10
= 63050
simple enough. There are other ways of arriving at the same value.
chris
More information about the thelist
mailing list