i need to code a function that converts an array of 64 bits into a hexadecimal value, the one is tested gives me correct value except for the last hexadecimal letter, can anyone tell me why is this happening or provide me a solution ? thank you in advance
Code:
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <fstream>
#include <cstdlib>
#include <string>
typedef unsigned __int64 Ebyte;
#define length 64
void to_tab(Ebyte cle,int tab[])
{
for(int i=0;i<length;i++)
tab[i]=(cle >> i) & 0x1;
}
Ebyte to_hex(int T[64])
{
Ebyte temp=0;
for(int i=0;i<64;i++)
temp+=T[i]*pow(2,i);
return temp;
}
void main ()
{Ebyte cle=0xabcdef2748493956,cle2;int test[64];
to_tab(cle,test);printf("la table est :\n");
for(int i=0;i<64;i++)
{if(i%8==0) printf("\n");printf("%d\t",test[i]);}
cle2=to_hex(test);
printf("\nhex est : %I64x",cle2);
getch();
}