Contents

조회 수 77976 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
랜덤함수 사용시..

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
번호 분류 제목 글쓴이 날짜 조회 수
781 Etc [link] 유용한 사이트 링크. hooni 2013.08.19 130284
780 Etc 베지어 곡선 (Bezier curve) file hooni 2013.08.18 238921
779 Etc [web] 제로보드 XE 템플릿에서 if문에 대해서 알아봅시다 hooni 2013.08.16 24746
778 Develop 아이 훌레시 작업중 ㅋㅋ secret hooni 2013.08.09 0
777 Develop [ios] 최신 UI 모음.. (나중에 정리할 것) secret hooni 2013.08.09 0
776 Develop [ios] UI컨트롤러 샘플코드 hooni 2013.08.08 16489
775 Develop [ios] libxml/tree.h file not found file hooni 2013.08.08 21280
774 Develop [ios] 소소한 팁 (Rect,Point,Path,URL 등) hooni 2013.08.08 32640
773 Develop [ios] Background 에서 네트워크 사용 file hooni 2013.07.22 13153
772 Develop [ios] App States file hooni 2013.07.22 14531
771 Etc 영어의 12 시제 (The twelve tenses of English) hooni 2013.07.12 17289
770 System/OS [mac] 컨텍스트(Context) 메뉴 "다음으로 열기" 내용 정리 hooni 2013.07.10 20361
Board Pagination Prev 1 ... 29 30 31 32 33 34 35 36 37 38 ... 99 Next
/ 99