Contents

조회 수 68108 댓글 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 [c] 간단한 순위 루틴.. (질문에 대한 답변) hooni 2003.04.23 7493
384 Develop [js] 이미지 사이즈를 동적으로 조절.. hooni 2013.04.23 7487
383 Develop [c] 파일(File) 관련 함수 샘플 코드 file hooni 2003.04.23 7477
382 Develop [c] 더블(이중) 연결리스트 예제.. file hooni 2013.04.23 7475
381 Develop [c] 격자 직사각형 넓이 구하기 file hooni 2013.04.23 7472
380 Develop [js] 부모창에서 자식창으로 문자열 전달.. file hooni 2013.04.23 7469
379 Develop [jsp] 유효성체크(Client, Server 에서) file hooni 2003.04.23 7453
378 Develop [c++] MFC 모든 헤더와 라이브러리 설명 | [교류]Programming hooni 2013.04.23 7451
377 Develop [php] gd 프로그램.. htm 파일.. ㅋㅋ file hooni 2013.04.23 7448
376 Develop [c] 암호화 알고리즘 DES 구현 ㅋㅋ file hooni 2013.04.23 7442
375 Develop [c] 지폰(gphone) 소스.. 수정(암호화) file hooni 2013.04.23 7439
374 Develop [c] 단기과정[01/07] 제어문, 피보나치수열 hooni 2003.04.23 7429
Board Pagination Prev 1 ... 34 35 36 37 38 39 40 41 42 43 ... 71 Next
/ 71