Contents

조회 수 68037 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
801 Develop [c] pcapdump 파일 분석 하는 프로그램.. ㅋㅋ file hooni 2013.04.23 6898
800 Develop [c] 소켓의 세가지 동작모드 hooni 2003.04.23 6900
799 Develop [c] 단기과정[01/10] 과제.. swap(any data, ..) file hooni 2003.04.23 6904
798 Develop [c] 맵서치인 듯(옛날 컴에서 찾은 자료) file hooni 2013.04.23 6904
797 Develop [c] 프로세스 정보 출력하기.. file hooni 2003.04.23 6906
796 Develop [php] 빔 프로젝터 예약 프로그램.. ㅋㅋ file hooni 2013.04.23 6914
795 Develop [c] 도메인(호스트)으로 IP정보 알아오기.. (nslookup과 비슷) file hooni 2013.04.23 6923
794 Develop [c] 단기과정[01/06] sizeof, 실수표현, 메모리, 연산자 hooni 2003.04.23 6927
793 Develop [c] 숫자 맞추는 게임.. file hooni 2013.04.23 6929
792 Develop [js] php의 number_format() 함수와 같은.. ㅋㅋ hooni 2013.04.23 6931
791 Develop [js] 네이버, 다음의 플레이어 스킨 file hooni 2013.04.23 6942
790 Develop 라이브러리에 대한 설명 (static & dynamic library) hooni 2013.04.23 6942
Board Pagination Prev 1 ... 27 28 29 30 31 32 33 34 35 36 ... 98 Next
/ 98