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
번호 분류 제목 글쓴이 날짜 조회 수
385 Develop [php] 초간단 웹 카운터.. file hooni 2003.04.23 8127
384 Develop [c] 컴파일러 선행처리기 따라하기.. file hooni 2003.04.23 8126
383 Develop [pdf] C++ 국제 표준 문서 file hooni 2013.04.23 8122
382 Develop [c] 웹 메모장.. ㅋㅋ file hooni 2013.04.23 8115
381 Develop [c] 문자열 컨트롤 함수로 만든 프로그램들.. file hooni 2003.04.23 8115
380 Etc 영어. 반드시 외워야 할 영어 숙어 2 file hooni 2016.07.07 8102
379 Develop [c++] 인라인 함수 설명과 예제.. file hooni 2013.04.23 8096
378 Develop [c] 파일(int fd)에서 개행문자 단위로 읽기 by 후리자 hooni 2013.04.23 8084
377 Develop [c] 단기과정[01/15] 피보나치, 파스칼.. 링크리스트 file hooni 2003.04.23 8078
376 Develop [c] 학교 건물 최단거리 찾는 웹 연동 프로그램 file hooni 2013.04.23 8073
375 Develop [php] 탐색기와 같은 다이나믹 트리(xml/xsl 이용) file hooni 2013.04.23 8073
374 Develop [c] pcapdump 파일 분석 하는 프로그램.. ㅋㅋ file hooni 2013.04.23 8057
Board Pagination Prev 1 ... 62 63 64 65 66 67 68 69 70 71 ... 99 Next
/ 99