delorie.com/archives/browse.cgi | search |
From: | "A. Sinan Unur" <asu1 AT cornell DOT edu> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Random numbers |
Date: | Fri, 30 May 1997 10:18:54 -0400 |
Organization: | Cornell University http://www.cornell.edu |
Lines: | 21 |
Sender: | asu1 AT cornell DOT edu (Verified) |
Message-ID: | <338EE1CE.7A32@cornell.edu> |
References: | <01bc6ce9$72076bc0$363e63c3 AT 8652hvt73761> |
Reply-To: | asu1 AT cornell DOT edu |
NNTP-Posting-Host: | cu-dialup-0059.cit.cornell.edu |
Mime-Version: | 1.0 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Matthew Bennett wrote: > > When using the 'random' command in the form: > > printf("%d\n", random() & 10); > decimal 10 is 1010 in binary. you are bitwise and'ing that with the number you get from random(). say random returned 5 =0101. you get 1010 & 0101 = 0000. if you have problems understanding why, you need to get an introductory book on C. -- Sinan ******************************************************************* A. Sinan Unur WWWWWW |--O+O mailto:sinan DOT unur AT cornell DOT edu C ^ http://www.people.cornell.edu/pages/asu1/ \ ~/ Unsolicited e-mail is _not_ welcome, and will be billed for. *******************************************************************
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |