From: Soenke_Ufen AT kruemel DOT org (Soenke Ufen) Newsgroups: comp.os.msdos.djgpp Subject: Re: Looking at the individual bits of a float. Date: Thu, 9 Nov 2000 12:10:00 CET Organization: Krmel Boks! Lines: 34 Sender: Soenke_Ufen AT kboks DOT kruemel DOT org Message-ID: References: <6fqO5.60817$mv2 DOT 276178 AT news2-win DOT server DOT ntlworld DOT com> NNTP-Posting-Host: pd4b9de86.dip.t-dialin.net (212.185.222.134) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 973769414 1660173 212.185.222.134 (16 [23622]) User-Agent: VSoup v1.2.9.48Beta [OS/2] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi Graham, g>I was wondering if anyone has any fast ways of looking at the g>individual bits and bytes of a float with or without (preferably) g>destroying the float in question. #include "pls_excuse_wrong_NG.h" #include #include /* CHAR_BIT */ int main() { float x; char *b; int i, j; scanf("%f", &x); b = (char *) &x; for (i = 0; i < sizeof(float); i++) { for (j = CHAR_BIT - 1; j >= 0; j--) { if (b[i] & (1 << j)) printf("1"); else printf("0"); } } printf("\n"); }/* Optimization depends on implementation ;-) */ -- Bye, Sönke.