Les Snippets

Connexion

Conversion Hexadécimal -> Décimal

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 22/04/2006 19:59:48 et initié par Willi [Liste]
Date de mise à jour : 27/07/2007 18:09:27
Vue : 41049
Catégorie(s) : Chaîne de caractères, Divers
Langages dispo pour ce code :
- VB6, VBA
- VB 2005, VB.NET 1.x
- PHP 3, PHP 4, PHP 5
- C# 1.x, C# 2.x
- Java
- C++
- Delphi 5
- C
- Windev
- Python



Langage : VB6 , VBA
Date ajout : 22/04/2006
Posté par Willi [Liste]
DateMAJ : 13/03/2007
Function HexaToDec(ValHex As String) As Long
  HexaToDec = Val("&H" & ValHex & "&")
End Function 
Langage : VB.NET 1.x , VB 2005
Date ajout : 23/04/2006
Posté par FREMYCOMPANY [Liste]
DateMAJ : 13/03/2007
Public Module _Nbr
   Public Function HexaToDec(ValHex As String) As Integer
      Return Val("&H" & ValHex & "&")
   End Function
   Public Function DecToHexa(ValDec as Integer) As String
      Return Hex(ValDec)
   End Function
End Module
Langage : PHP 3 , PHP 4 , PHP 5
Date ajout : 24/04/2006
Posté par malalam [Liste]
<?php
$numberDec = hexdec ($sHexa); 
?>
Langage : C# 1.x , C# 2.x
Date ajout : 27/04/2006
Posté par Bidou [Liste]
DateMAJ : 12/08/2006

// Hexadecimal to Decimal
public static int HexToDec(string hexValue) 
{
   return Int32.Parse(hexValue, System.Globalization.NumberStyles.HexNumber); 
}

// Decimal to Hexadecimal
public static string DecToHex(int decValue) 
{
   return string.Format("{0:x}", decValue); 
}

// Utilisation
string hex = DecToHex(15); 
int dec = HexToDec("f");







Langage : Java
Date ajout : 12/07/2006
Posté par Twinuts [Liste]
int n = Integer.parseInt("FF", 16);
System.out.println(n);
Langage : C++
Date ajout : 12/07/2006
Posté par Twinuts [Liste]
#include <iostream>
#include <string>
#include <sstream>
std::string s = "FF";
std::istringstream iss(s.c_str()); 
unsigned int x;
iss >> hex >> x;
std::cout << x;

Langage : Delphi 5
Date ajout : 05/08/2006
Posté par f0xi [Liste]
DateMAJ : 14/03/2007
I := StrToInt('$1A2B3C4D');
ou
I64 := StrToInt64('$1A2B3C4D5E6F');


Langage : C
Date ajout : 10/08/2006
Posté par BruNews [Liste]
DateMAJ : 27/07/2007
DWORD __stdcall HexaToDecimal(const char* pszHexa)
{
  DWORD ret = 0, t = 0, n = 8, c;
  while(c = *pszHexa) {
    if((c >= '0') && (c <= '9')) t = (c - '0');
    else if((c >= 'A') && (c <= 'F')) t = (c - 'A' + 10);
    else if((c >= 'a') && (c <= 'f')) t = (c - 'a' + 10);
    else break;
    ret *= 16; ret += t;
    pszHexa++;
    if(--n == 0) break;
  }
  return ret;
}

Langage : Windev
Date ajout : 11/05/2007
Posté par drcharly93 [Liste]
PROCEDURE HexaToDec( ValHex )
 RENVOYER Val( NumeriqueVersChaine( ValHex, "8d" )
PROCEDURE DecToHexa ( ValNumerique )
 RENVOYER NumeriqueVersChaine( ValNumerique, "x" )

Langage : Python
Date ajout : 19/12/2007
Posté par 0x586e [Liste]
# Decimal à hexadecimal
dh = lambda d: '%X' % d
# Hexadecimal à Decimal
hd = lambda h: int(h,16)

Remarque :
Utilisation:
print hd('0xFF')
affiche : 255

Snippets en rapport avec : Convertir, Base 10, Base 16, Hexa, Decimal



Codes sources en rapport avec : Convertir, Base 10, Base 16, Hexa, Decimal

{Visual Basic, VB6, VB.NET, VB 2005} CALCULATRICE DEC/HEXA AVEC PAPIER VIRTUEL
Ceci est le enieme calculatrice. Elle sort le resultat en Decimal et en Hexa en meme temps sur 2 aff...

{Visual Basic, VB6, VB.NET, VB 2005} VISUALISATION FAÇON DUMP DE TOUT FICHIER, EN HEXA OU EN DÉCIMAL.
Le but est d'analyser les octets de tout fichier pour en connaître la constitution, ou vérifier une ...

{Visual Basic, VB6, VB.NET, VB 2005} CONVERTIR UNE COULEUR HEXA HTML EN DECIMAL VB (LA VRAI FONCTION)
suite aux conneries que j'ai vu sur ce site genre Public Function InvHex(ValHex As String) As Str...

{C / C++ / C++.NET} CHAINE EN HEXA (WIN32)
Pour question récurrente sur forum. char* __fastcall bnStrToHex(char *szsrc, char* szdst); retou...

{Delphi} DATE EN ARABE
C'est un petit programme qui convertit la date du jour en langue Arabe. La fonction intégrée conver...

{Javascript / DHTML} CONVERSION TEXTE ACCENTUÉ -> CODE HTML
Etant donné que je n'ai pas trouvé de code qui permettait de me générer un code HTML à partir d'un t...

{IRC} AMICODER CONVERSION AUDIO V1.0
Cet addon vous permet de convertir differents formats audio dans d'autres formats. Il transfert éga...

{C / C++ / C++.NET} MORSEPLAYER, JOUER UN MESSAGE MORSE
Voici une source qui code un texte en morse pour le jouer ensuite. Il permet ainsi de "jouer des tex...

{Visual Basic, VB6, VB.NET, VB 2005} CRÉER UN(DES) RENDEZ-VOUS/ DEMANDE(S) DE RÉUNION À PARTIR D'EMAIL(S)
Permet de créer un rendez-vous/une demande de réunion à partir d'un email. La macro fonctionne égale...

{C / C++ / C++.NET} CONVERTIRREPERTOIRE, CONVERTISSEUR DE FICHIERS IMAGES AVEC FREEIMAGE: BMP, JPG, PNG -> BMP, JPG...
Il s'agit d'un convertisseur de fichier images qui traite un dossier complet. Il vous permet de con...