Views 68041 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
677 Develop [c] 이진트리(binary tree)의 특성 file hooni 2003.04.23 9598
676 Develop [js] Closure를 이용해 캡슐화.. hooni 2013.12.16 9594
675 Develop [c++] 마방진 소스코드 file hooni 2013.04.23 9558
674 Develop [c++] 링크리스트(linked list) 클래스(스택,큐) file hooni 2003.04.23 9553
673 Develop [c] 파일(File)의 연결과 연결 해제 (link, unlink, chown) hooni 2013.04.23 9543
672 Develop [c] 팩토리얼.. - 재귀함수 hooni 2003.04.23 9500
671 Develop [java] 거스름돈 계산.. swing 사용 file hooni 2013.04.23 9442
670 Develop [java] 스윙(swing)버튼 테스트 ㅋㅋ file hooni 2013.04.23 9421
669 Develop [js] jQuery 셀랙터(selector) 요약 hooni 2013.12.17 9418
668 Etc [english] 영어공부 혼자 하기, 인터넷으로 영어공부하기 추천사이트 20선 file hooni 2013.11.25 9408
667 Develop [c] 공용체를 이용해 MSB를 LSB로 변환 file hooni 2013.04.23 9374
666 Develop [c] 다중연결 서버 만들기 #2 - select() 사용 file hooni 2013.04.23 9361
665 Develop [java] Sieve of Eratosthenes (에라토스테네스의 체) hooni 2013.04.23 9337
664 System/OS [linux] 초간단 Postfix, Covecot, SSL/TLS (SMTP) file hooni 2017.12.11 9323
663 Develop [c++] MFC로 만든 디렉토리/파일 파인더 file hooni 2013.04.23 9323
662 Develop [c++] 더블 링크리스트(linked list) 학습용 초간단 단어장 file hooni 2003.04.23 9323
Board Pagination Prev 1 ... 30 31 32 33 34 ... 74 Next
/ 74