Views 68041 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
랜덤함수 사용시..

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
No. Category Subject Author Date Views
117 System/OS 무료로 HTTPS 적용하기 (Lets' Encrypt) file hooni 2017.02.16 2174
116 Etc 모바일 프로그래머가 갖추어야 할 필수 역량 file hooni 2017.02.16 1293
115 Develop [ios] Facebook Cache 갱신하는 함수 file hooni 2017.02.27 1178
114 Develop [js] Javascript로 만든 포트리스 (2010) 5 file hooni 2017.03.03 2500
113 Etc 종합시험 관련 자료 secret hooni 2017.03.15 0
112 Develop [ios] 동영상 플레이어 샘플 (for PIP Player) file hooni 2017.03.15 1258
111 Develop Mac OS 에 Jenkins 설치하기 (Homebrew) 2 file hooni 2017.03.15 8091
110 Develop 사이버보안실무 수업 메모 secret hooni 2017.03.23 0
109 Develop [ios] Xcode에서 특정 파일만 ARC 따로 설정하는 방법 file hooni 2017.03.29 944
108 Database [mysql] 쿼리 실행시 ERROR 1366 (HY000) : incorrect string value : for column 3 hooni 2017.03.30 8776
107 Etc 사이버보안실무 수업 메모 hooni 2017.03.30 807
106 Develop [ios] 비디오,네트워크,소셜로그인 테스트 file hooni 2017.04.04 684
105 Develop [ios] NSString, RegularExpression Find/Replace hooni 2017.04.14 834
104 Develop [ios] Facebook SDK 로그인 설명 file hooni 2017.04.19 1156
103 Etc 사이버보안실무 시험. secret hooni 2017.04.20 0
102 Develop [ios] 코코아 프로그래밍의 네이밍 룰(명명 규칙) hooni 2017.05.11 1179
Board Pagination Prev 1 ... 65 66 67 68 69 ... 74 Next
/ 74