Contents

조회 수 68056 댓글 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 [c] 텍스트 파일(로그)을 정해진 라인 단위로 쪼개주는 코드 file hooni 2013.04.23 7050
536 Develop [c] 네트워크 트래릭 모니터링.. 졸업작품.. 2 file hooni 2013.04.23 11051
535 Develop [c#] MS IE(Internet Explorer) 툴바 버튼 예제 2003/2005 두가지 버전 secret hooni 2013.04.23 2090
534 Develop [c#] BFilter 툴바 소스 코드 ㅎㅎ file hooni 2013.04.23 7610
533 Develop [c++] mfc로 만든 현재 디렉토리 읽어오기/세팅하기 (GetCurrentDirectory/SetCurrentDirectory) file hooni 2013.04.23 8470
532 Develop 다운 받아서 테스트 해볼것.. hooni 2013.04.23 9143
531 Develop [c++] mfc 기반 멀티수납(wall)시스템 소스와 실행파일 file hooni 2013.04.23 7056
530 Develop [c++] mfc 기반 레지스트리(registry) 컨트롤 예제 코드 2 hooni 2013.04.23 15337
529 Develop [c] kmp 활용 search file hooni 2013.04.23 7420
528 Develop [c] 문자열 str_shift 예제.. file hooni 2013.04.23 6843
527 Develop [c++] winsock을 이용한 서버,클라이언트와 ssl서버,클라이언트 file hooni 2013.04.23 7614
526 Develop [c++] mfc이용한 트레이아이콘(TrayIcon) 클래스 예제 프로젝트 file hooni 2013.04.23 9253
Board Pagination Prev 1 ... 49 50 51 52 53 54 55 56 57 58 ... 98 Next
/ 98