Contents

조회 수 78048 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
231 Develop [vbs] CD롬 뱉는 스크립트.. hooni 2003.04.23 12672
230 Develop [c++] String Tokenizer (나중에 c 코드로 변경해서 사용할 것) hooni 2013.04.23 12693
229 Develop [c++] 기초강좌 #02(레퍼런스,메모리할당) hooni 2003.04.23 12697
228 Develop [c++] RSA Sample 4 CPP hooni 2013.04.23 12732
227 Develop [php] 배열 관련 함수 설명 ㅎㅎ hooni 2003.04.23 12749
226 Develop 페이팔에서 돈 찾기 (Paypal withdraw) file hooni 2014.02.20 12755
225 Develop [c] 테트리스(Tetris) 게임(도스용) 소스코드 file hooni 2003.04.23 12781
224 Develop [c] 시간 관련 함수 설명과 예제.. file hooni 2003.04.23 12785
223 Develop [c++] 기초강좌 #04(클래스) hooni 2003.04.23 12809
222 Develop [php] whois정보 조회 프로그램 hooni 2003.04.23 12839
221 Develop [swift] NotificationCenter 간단 예제 file hooni 2021.01.27 12858
220 Develop [unix] 유닉스 명령에 메타문자 사용 hooni 2014.02.19 12867
Board Pagination Prev 1 ... 47 48 49 50 51 52 53 54 55 56 ... 71 Next
/ 71