Contents

조회 수 68119 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
469 Develop [c] 하노이탑 - 재귀함수 hooni 2003.04.23 9178
468 Develop [c] 학교 건물 최단거리 찾는 웹 연동 프로그램 file hooni 2013.04.23 6828
467 Develop [c] 학생명단 관리 프로그램 소스 ㅋㅋ 1 file hooni 2003.04.23 7815
466 Develop [c] 한글 문자열 출력 hooni 2015.11.10 1789
465 Develop [c] 함수 목록과 예제 소스 파일 file hooni 2013.04.23 7210
464 Develop [c] 함수 요약 (검색해서 쓰세요..) hooni 2003.04.23 8834
463 Develop [c] 확인해 볼거.. ㅡ,.ㅡ; file hooni 2013.04.23 7174
462 Develop [c][cpp] mfc, win32api, 예제 소스 대박 모음~ file hooni 2013.04.23 8479
461 Develop [c][java] 그래픽(graphic)관련 자료와 샘플코드.. file hooni 2013.04.23 9218
460 Develop [c][java] 소켓 프로그래밍(채팅 서버 C, 클라이언트 Java) file hooni 2003.04.23 7030
459 Develop [c][java] 주사선 채우기 알고리즘(scan line filling algorithm) 구현 file hooni 2013.04.23 8990
458 Develop [c][php] 프로세스정보와 메모리 정보 웹으로 출력하는거.. file hooni 2013.04.23 6345
Board Pagination Prev 1 ... 27 28 29 30 31 32 33 34 35 36 ... 71 Next
/ 71