Contents

조회 수 68056 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
13 Develop 알고리즘 성능 분석 기준 hooni 2014.06.24 2794
12 Develop 알고리즘 성능분석 file hooni 2014.06.24 2974
11 Develop 웹페이지 성능 테스트 툴 설명 hooni 2013.04.23 27449
10 Develop 이어서 작업할 내용~ secret hooni 2013.11.21 0
9 Develop 자주 쓰는 Docker 명령어 alias hooni 2020.01.10 269947
8 Develop 정리할 자료. file hooni 2015.07.02 679
7 Develop 참고하고 지울 자료.. 집에서 바야지.. ㅋㅋ file hooni 2013.04.23 12129
6 Develop 최근 논문 자료 (2011/01/03, 만현형한테 보낸거..) secret hooni 2013.04.23 10366
5 Develop 캘리포니아 운전면허 족보 file hooni 2017.06.12 744
4 Develop 페이팔에서 돈 찾기 (Paypal withdraw) file hooni 2014.02.20 11390
3 Develop 프로그래밍 소스 관련 사이트.. hooni 2013.04.23 16486
2 Develop 프로그래밍에서 foo, bar 함수의 유래 file hooni 2013.06.25 21265
Board Pagination Prev 1 ... 62 63 64 65 66 67 68 69 70 71 Next
/ 71