조회 수 68125 추천 수 0 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
45 Develop [vb] 비주얼 베이직 173페이지 hooni 2003.04.23 54922
44 Develop [vb] 비쥬얼 베이직 기출 문제 연습2 hooni 2003.04.23 54455
43 Develop [vb] 비쥬얼 베이직으로.. hooni 2003.04.23 53133
42 Develop [ios] UIAlertView 초간단 샘플 ㅎㅎ hooni 2013.10.14 46203
41 Develop [ios] 미스터피자(Mr.pizza) 어플 file hooni 2013.04.23 42696
40 Develop [ios] iOS 4.0 beta 에서 3.1.3으로 다운그레이드 하는 법 file hooni 2013.04.23 37543
39 Develop [lego] 세그웨이 이것만 볼것.. ㅎㅎ file hooni 2013.04.23 33589
38 Develop [android] 디바이스(시뮬레이터) hosts 파일 수정하기 hooni 2013.04.23 31132
37 Develop [js] 웹페이지에서 특정 엘리먼트 드래그, 복사, 컨텍스트메뉴, 키보드 막기 hooni 2013.11.04 30138
36 Develop [ios] 소소한 팁 (Rect,Point,Path,URL 등) hooni 2013.08.08 29535
35 Develop [c#] 웹문서 소스(html) 긁어오기 file hooni 2013.04.23 24578
34 Develop [vb] 문자열에서 태그 제거함수 (Visual Basic) file hooni 2013.04.23 22681
33 Develop [ios] UIView에서 상위 UIViewController 가져오기 hooni 2013.09.27 20257
32 Develop [java] 입출력 스트림 3부 (오브젝트) hooni 2013.04.23 17183
31 Develop [android] 안드로이드 어플 모음 ㅎㅎ secret hooni 2013.04.23 16340
30 Develop [java] 입출력 스트림 1부 (문자) file hooni 2013.04.23 15358
Board Pagination Prev 1 2 3 4 Next
/ 4