| [ KAIST ] in KIDS 글 쓴 이(By): cdpark (박종대) 날 짜 (Date): 2002년 3월 29일 금요일 오전 12시 49분 26초 제 목(Title): Re: [질문]간단한 수학문제.. 많이 봐주세� rand()의 결과는 하위 비트 쪽이 더 나쁩니다. 그래서 보통은 상위 비트를 쓰거나 중간 비트를 꺼내 씁니다. rand() 함수보다 더 나은 random() 등의 함수를 쓰는 것도 한 방법이고요. 아래는 Linux에서 man 3 rand로 본 결과의 일부입니다. RAND(3) Linux Programmer's Manual RAND(3) ... DESCRIPTION ... In Numerical Recipes in C: The Art of Scientific Computing (William H. Press, Brian P. Flannery, Saul A. Teukolsky, William T. Vetterling; New York: Cambridge University Press, 1992 (2nd ed., p. 277)), the following comments are made: "If you want to generate a random integer between 1 and 10, you should always do it by using high-order bits, as in j=1+(int) (10.0*rand()/(RAND_MAX+1.0)); and never by anything resembling j=1+(rand() % 10); (which uses lower-order bits)." --- 박.. |