Contents

조회 수 68050 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
537 Develop [java] RGB 색상 조절 버튼.. 스윙(swing) file hooni 2013.04.23 7837
536 Develop [linux] 프로세스 관련 시스템콜 hooni 2003.04.23 7827
535 Develop [c] i2osp 임시로.. ㅋㅋ file hooni 2003.04.23 7821
534 Develop [c] fgets() 함수 사용하기.. hooni 2003.04.23 7819
533 Develop [c] 소수 구하기 #1 (한정된 숫자 내에 있는 소수 걸러내기) hooni 2003.04.23 7811
532 Develop [c] 이진트리(binary tree) 샘플소스 (삽입, 삭제, 운행) file hooni 2003.04.23 7807
531 Develop [mysql] 양력, 음력 DB데이터 file hooni 2013.04.23 7802
530 Develop [jsp] HelloServlet 출력문 file hooni 2003.04.23 7796
529 Develop [asp] 문자열 관련 함수 요약 hooni 2013.04.23 7780
528 Develop [c] 근의 공식으로 2차방정식 풀기.. file hooni 2003.04.23 7775
527 Develop [c] 학생명단 관리 프로그램 소스 ㅋㅋ 1 file hooni 2003.04.23 7771
526 Develop [c] 단기과정[01/08] (다차원 + 배열)포인터, void 포인터 hooni 2003.04.23 7770
Board Pagination Prev 1 ... 49 50 51 52 53 54 55 56 57 58 ... 98 Next
/ 98