delorie.com/archives/browse.cgi | search |
From: | Ryan Blazecka <eblazecka AT bc DOT sympatico DOT ca> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: rand() or random() |
Date: | Mon, 03 Nov 1997 23:20:44 -0800 |
Organization: | BCTEL Advanced Communications |
Lines: | 13 |
Message-ID: | <345ECCCC.6056@bc.sympatico.ca> |
References: | <63mh1a$9r4$1 AT postern DOT mbnet DOT mb DOT ca> |
Reply-To: | eblazecka AT bc DOT sympatico DOT ca |
NNTP-Posting-Host: | srry01m02-121.bctel.ca |
Mime-Version: | 1.0 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Mark Phillips wrote: > Just for the heck of it, say I want to get a random number from 0 to > 19. rand() and random() appear to return numbers from 0 to 2^31. I > could always do rand() * 20 / 2^31 but there must be a better way. How about rand() % 19? :) (BTW, you should use random() instead of rand(), its numbers are more "random") -- [ Ryan Blazecka -- http://www.deninc.com/~corrosion/ ] [ _corrosion_ AT geocities DOT com OR eblazecka AT bc DOT sympatico DOT ca ]
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |