Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/12/2009, 15:09
Avatar de ClubIce
ClubIce
 
Fecha de Ingreso: diciembre-2008
Mensajes: 216
Antigüedad: 16 años, 1 mes
Puntos: 2
Pregunta Convertir Hexadecimal a Decimal

Hola,

lo que pasa esque estoy haciendo una aplicacion y en la cual nesesito pasar decimales a hexadecimales y viseversa.
Yo ya hize la que combierte dec a hex:
Código javascript:
Ver original
  1. function getRes (a,b) {
  2.   return a-(parseInt(a/b)*b)
  3. }
  4. function decToHex(n) {
  5.     hexStr="0123456789ABCDEF"
  6.     res=0;
  7.     var Hex=""
  8.     for (i=0; i<(""+n).length; i++) {
  9.       res=getRes(n,16)
  10.       n=parseInt(n/16)
  11.       Hex=hexStr.charAt(res)+Hex;
  12.       if (n<16) {
  13.     Hex=hexStr.charAt(n)+Hex;
  14.     break
  15.       }
  16.     }
  17.     return Hex
  18.   }

esta funcion me anda bien pero o se como hacer para combertir hexadecimales a decimales.
porfavor si alguien sabe el procedimiento o tiene la funcion porfavor pasemelo

gracias de antemano.