delorie.com/archives/browse.cgi | search |
From: | Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Binary Numbers |
Organization: | Pin Eight Software http://pineight.8m.com/ |
Message-ID: | <7j2sgs0nnetaqqdd5i60qk8nn9p1mmsrg1@4ax.com> |
References: | <390C9311 DOT E12D0FB3 AT pop DOT gis DOT net> |
X-Newsreader: | Forte Agent 1.7/32.534 |
MIME-Version: | 1.0 |
Lines: | 28 |
X-Trace: | /KHlxIIRY+00KVkhEgU6YsM1FzHO4ICQVDjSA+s0K4jRpu2n0AWKvrmyL8gOAacvoF5yN8lokJFD!ibZNhOuga9dyH+WIPZFQFk2cpfAgz044Jms3q1ZjaUkLNPmaPIn6B+/IYI29CDx7QEiSyEgbkzIR!ATnz4zY= |
X-Complaints-To: | abuse AT gte DOT net |
X-Abuse-Info: | Please be sure to forward a copy of ALL headers |
X-Abuse-Info: | Otherwise we will be unable to process your complaint properly |
NNTP-Posting-Date: | Mon, 01 May 2000 22:58:11 GMT |
Distribution: | world |
Date: | Mon, 01 May 2000 22:58:11 GMT |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
On Sun, 30 Apr 2000 16:09:53 -0400, Joseph Rose <jorose AT pop DOT gis DOT net> wrote: >Binary Numbers >How do I represent them in C++? On most platforms (including DJGPP): int x; You can retrieve bit n of integer x by doing this: foo = (x >> n) & 1; If you want to print the binary number, you can loop from n = 31 to 0 to display the number in base 2, or you can use good old itoa(). By "most platforms" I mean the ones that use binary arithmetic for objects of type `int'. I challenge comp.os.msdos.djgpp to find an important computer platform that does not. -- Damian Yerrick "I refuse to listen to those who refuse to listen to reason." See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html This is McAfee VirusScan. Add these two lines to your signature to prevent the spread of signature viruses. http://www.mcafee.com/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |