조회 수 78020 추천 수 0 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
1177 Develop '2014 모바일 개발 트렌드' 발표자료입니다. file hooni 2014.10.02 2538
1176 System/OS Apache CORS 설정 1 hooni 2020.09.04 6140
1175 Develop Aspect Oriented Programming in Objective-C hooni 2015.05.18 3259
1174 System/OS asx미디어 정보 기록.. hooni 2003.04.23 22156
1173 System/OS Brave Browser for Debian, Ubuntu, Mint file hooni 2024.10.23 6964
1172 System/OS CentOS 6.5 USB 설치 6 file hooni 2013.12.18 39986
1171 System/OS CentOS 에서 Cacti 설치하기 hooni 2015.01.02 3188
1170 System/OS Configure Postfix to Use Gmail SMTP on Ubuntu 18.04 file hooni 2020.02.07 12245
1169 Develop DDay Memo 1.9.4 소스코드 secret hooni 2015.10.03 0
1168 Etc EBS [수학영역] 미적분과 통계 기본 - 정규분포의 의미와 특징은? hooni 2015.04.20 2671
1167 System/OS Enable Safari Hidden Debug Menu in Mac OS X file hooni 2017.02.07 7624
1166 System/OS Enable the Develop Menu in Safari file hooni 2017.02.07 4103
1165 Develop GCM 사용하기 2 (단말에 GCM 구현하기) file hooni 2013.07.06 24652
1164 Develop GCM 사용하기 3 (JSP로 GCM 푸시 서버 만들기) 4 file hooni 2013.07.06 27132
1163 Develop git 브런치 배우기 (링크) hooni 2013.07.09 22080
1162 Develop GPL, AGPL, MPL,.. 한눈에 보는 오픈소스SW 라이선스 file hooni 2014.10.14 2066
Board Pagination Prev 1 2 3 4 5 ... 74 Next
/ 74