Views 68043 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
랜덤함수 사용시..

iOS
There are several built-in randomizers on the iPhone, and most people's first thought is to use rand() after seeding it by calling

srandom(time(NULL));

But... rand() is really not a very good PRNG. random() is a little better, but still less then ideal. Fortunately, these are not the only ones available on the iPhone. Personally, I like arc4random() because it's a decent pseudo-random algorithm and has twice the range or rand().

On the iPhone, RAND_MAX is 0x7fffffff (2147483647), while arc4random() will return a maximum value of 0x100000000 (4294967296), giving much more precision. You also don't need to seed arc4random(), as the first call to it automatically seeds it. 

결론은 arc4random() 을 사용하자.

[출처] http://iphonedevelopment.blogspot.com/2008/10/random-thoughts-rand-vs-arc4random.html

?

List of Articles
No. Category Subject Author Date Views
325 System/OS [linux] 이기종간의 파일 공유(Samba) hooni 2003.04.23 14900
324 Develop [linux] 임베디드 리눅스 (embedded linux) file hooni 2013.04.23 7354
323 System/OS [linux] 종료와 종료코드 확인(환경변수에서) hooni 2003.04.23 15543
322 System/OS [linux] 처음 설치부터 APM 설치까지 (업데이트 할 것) hooni 2013.04.23 38271
321 System/OS [linux] 초간단 Postfix, Covecot, SSL/TLS (SMTP) file hooni 2017.12.11 9327
320 System/OS [linux] 초간단 SquirrelMail 설치/설정 (다람쥐 메일) hooni 2017.12.11 4461
319 System/OS [linux] 최소한의 커널 설정(커널설치 전체과정) hooni 2003.04.23 17402
318 System/OS [linux] 커널 컴파일, 설정 hooni 2003.04.23 17845
317 System/OS [linux] 콘솔 기본언어 설정 방법 hooni 2013.04.23 12826
316 System/OS [linux] 콘솔/Xwindow 에서 PC스피커 소리 없애기 hooni 2003.04.23 16352
315 System/OS [linux] 터미널에서 문자 깨질 때 설정 ㅋㅋ hooni 2003.04.23 13914
314 System/OS [linux] 텔넷, FTP 텍스트 모드에서 사용 hooni 2003.04.23 11939
313 System/OS [linux] 특수문자 환경 설정(stty) hooni 2003.04.23 15277
312 System/OS [linux] 특정 문자열 포함된 파일 찾는 명령어 hooni 2013.10.16 30613
311 System/OS [linux] 파일내 문자열 찾아 바꾸기 hooni 2013.04.23 12195
310 System/OS [linux] 패킷 스니퍼링 hooni 2003.04.23 16319
Board Pagination Prev 1 ... 52 53 54 55 56 ... 74 Next
/ 74