Conversion hexadecimal en float

Résolu
wantofirst Messages postés 7 Date d'inscription jeudi 29 juin 2006 Statut Membre Dernière intervention 21 juillet 2006 - 30 juin 2006 à 10:31
wantofirst Messages postés 7 Date d'inscription jeudi 29 juin 2006 Statut Membre Dernière intervention 21 juillet 2006 - 30 juin 2006 à 11:48
Salut
je recherche un code qui me permettra de convertir des resultat hexadecimal en float;ou est ce qu'il y'a une fonction en  C ou C++ qui nous permet de faire directement.
merci

l'homme qui marche debout
Wangrin The First

2 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
30 juin 2006 à 10:47
DWORD __stdcall HexaToDecimal(const char* pszHexa)
{  DWORD ret 0, t 0, n = 0;
  const char *c = pszHexa;
  while(*c && (n < 16)) {
    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;
    n++; ret *= 16; ret += t; c++;
    if(n >= 8) break;
  }
  return ret;
}

float f = (float) (int) HexaToDecimal(pszChaineHexa);

ciao...
BruNews, MVP VC++
3
wantofirst Messages postés 7 Date d'inscription jeudi 29 juin 2006 Statut Membre Dernière intervention 21 juillet 2006
30 juin 2006 à 11:48
je te remercie beaucoup

l'homme qui marche debout
Wangrin The First
0
Rejoignez-nous