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++][mfc] 파일 입출력 샘플 (한줄씩 읽어서 다른 파일에 쓰기) hooni 2013.04.23 15052
468 Develop [c++] mfc 이용한 기본적인 형변환 예제 hooni 2013.04.23 11502
467 Develop [c++] mfc 이용한 트레이아이콘(TrayIcon) 클래스 예제 프로젝트 file hooni 2013.04.23 8826
466 Develop [c++] mfc이용한 트레이아이콘(TrayIcon) 클래스 예제 프로젝트 file hooni 2013.04.23 9274
465 Develop [c++] winsock을 이용한 서버,클라이언트와 ssl서버,클라이언트 file hooni 2013.04.23 7639
464 Develop [c] 문자열 str_shift 예제.. file hooni 2013.04.23 6855
463 Develop [c] kmp 활용 search file hooni 2013.04.23 7434
462 Develop [c++] mfc 기반 레지스트리(registry) 컨트롤 예제 코드 2 hooni 2013.04.23 15374
461 Develop [c++] mfc 기반 멀티수납(wall)시스템 소스와 실행파일 file hooni 2013.04.23 7079
460 Develop 다운 받아서 테스트 해볼것.. hooni 2013.04.23 9172
459 Develop [c++] mfc로 만든 현재 디렉토리 읽어오기/세팅하기 (GetCurrentDirectory/SetCurrentDirectory) file hooni 2013.04.23 8512
458 Develop [c#] BFilter 툴바 소스 코드 ㅎㅎ file hooni 2013.04.23 7668
Board Pagination Prev 1 ... 27 28 29 30 31 32 33 34 35 36 ... 71 Next
/ 71