Old stuff/ecole_etude_fac_de_pau/licence_2/poo/binaire.cc
(Deskargatu)
/* tp3
* affichage binaire d un float
***********************************/
#include <iostream.h>
void bin(int a)
{
int tab[8];
int i;
for (i=0;i < 8;i++)
{
tab[i] = a % 2;
a= a / 2;
}
for (i=7;i>=0;i--)
{
cout << tab[i];
}
}
void aff(float *n)
{
unsigned char *t;
t = (unsigned char*)n;
for (int i=0;i<4;i++)
{
bin (*(t+i));
}
cout << "\n";
}
int main()
{
float f;
char test[9] = "test";
cout << "Entrez un entier a virgule : ";
cin >> f;
aff(&f);
}