14,977,142 members
Home / Discussions / C / C++ / MFC

# C / C++ / MFC

 Re: Library file redefinition error fefe.wyx10-Sep-07 17:05 fefe.wyx 10-Sep-07 17:05
 Re: Library file redefinition error palanirajan10-Sep-07 17:32 palanirajan 10-Sep-07 17:32
 Re: Library file redefinition error john563210-Sep-07 19:57 john5632 10-Sep-07 19:57
 Re: Library file redefinition error jhwurmbach10-Sep-07 21:50 jhwurmbach 10-Sep-07 21:50
 Upper limit of rand() function rp_suman10-Sep-07 15:45 rp_suman 10-Sep-07 15:45
 Re: Upper limit of rand() function fefe.wyx10-Sep-07 17:00 fefe.wyx 10-Sep-07 17:00
 Re: Upper limit of rand() function rp_suman10-Sep-07 17:36 rp_suman 10-Sep-07 17:36
 Loaded dice! Stephen Hewitt10-Sep-07 17:47 Stephen Hewitt 10-Sep-07 17:47
 I assume you’re using code like this: Copy Code `int val = rand()%10 + 1;` This will not produce evenly distributed random numbers! ‘rand’ generates random numbers from 0 to ‘RAND_MAX’ (32767). Below if a list of ranges, each range maps from 1 to 10 (e.g. 0->1, 1->2, ..., 10->1, 11->2, etc): 0-9 10-19 20-29 …. 32750-32759 32760-32767 (32769) Note the last range is smaller than the rest! The number in brackets is the value we would have to use as the maximum to make it the same size. Here’s a breakdown of the last range: 32760 -> 1 32761 -> 2 32762 -> 3 32763 -> 4 32764 -> 5 32765 -> 6 32766 -> 7 32767 -> 8 This means the numbers from 1-8 will be slightly more likely to occur than 9 and 10 because 1-8 appear in all ranges whereas 9 and 10 appear in all ranges except the last! If I were you I'd use Boost's Random[^] library. Steve
 Why is my atof() code doesn't work? TooShy2Talk10-Sep-07 15:45 TooShy2Talk 10-Sep-07 15:45
 Re: Why is my atof() code doesn't work? rp_suman10-Sep-07 15:51 rp_suman 10-Sep-07 15:51
 Re: Why is my atof() code doesn't work? TooShy2Talk10-Sep-07 15:57 TooShy2Talk 10-Sep-07 15:57
 Re: Why is my atof() code doesn't work? rp_suman10-Sep-07 16:30 rp_suman 10-Sep-07 16:30
 Re: Why is my atof() code doesn't work? TooShy2Talk10-Sep-07 20:13 TooShy2Talk 10-Sep-07 20:13
 Re: Why is my atof() code doesn't work? [modified] rp_suman11-Sep-07 5:45 rp_suman 11-Sep-07 5:45
 Re: Why is my atof() code doesn't work? TooShy2Talk11-Sep-07 18:01 TooShy2Talk 11-Sep-07 18:01
 Re: Why is my atof() code doesn't work? Nelek11-Sep-07 23:12 Nelek 11-Sep-07 23:12
 setup project Franken10-Sep-07 9:16 Franken 10-Sep-07 9:16
 Re: setup project David Crow10-Sep-07 10:29 David Crow 10-Sep-07 10:29
 Re: setup project Franken10-Sep-07 10:32 Franken 10-Sep-07 10:32
 Re: setup project David Crow10-Sep-07 10:37 David Crow 10-Sep-07 10:37
 Re: setup project Franken10-Sep-07 10:49 Franken 10-Sep-07 10:49
 Re: setup project David Crow10-Sep-07 11:06 David Crow 10-Sep-07 11:06
 Re: setup project Franken10-Sep-07 11:18 Franken 10-Sep-07 11:18
 Re: setup project carrivick11-Sep-07 11:09 carrivick 11-Sep-07 11:09
 Re: setup project Franken12-Sep-07 2:41 Franken 12-Sep-07 2:41
 Last Visit: 31-Dec-99 18:00     Last Update: 29-Jul-21 22:38 Refresh ᐊ Prev1...6014601560166017601860196020602160226023 Next ᐅ