Develop
2013.10.31 16:51
[ios] Random Thoughts: Rand() vs. arc4random()
조회 수 78057 댓글 0
랜덤함수 사용시..
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
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
1165 | Develop |
참고하고 지울 자료.. 집에서 바야지.. ㅋㅋ
![]() |
hooni | 2013.04.23 | 14095 |
1164 | Etc |
종합시험 관련 자료
![]() |
hooni | 2017.03.15 | 0 |
1163 | Etc | 정보시스템(정보보안)의 위험관리 설명 | hooni | 2013.04.23 | 20584 |
1162 | Develop |
정리할 자료.
![]() |
hooni | 2015.07.02 | 2107 |
1161 | Develop | 자주 쓰는 Docker 명령어 alias | hooni | 2020.01.10 | 289748 |
1160 | Etc | 인증서 *.p12 파일을 *.pem 파일로 변환 | hooni | 2015.04.30 | 3813 |
1159 | Etc | 이클립스(Eclipse) 유용한 단축키 ㅋㅋ | hooni | 2013.04.23 | 23202 |
1158 | Develop |
이어서 작업할 내용~
![]() |
hooni | 2013.11.21 | 0 |
1157 | Develop | 웹페이지 성능 테스트 툴 설명 | hooni | 2013.04.23 | 28462 |
1156 | Etc |
웹 보안 논문 주제 2016
![]() |
hooni | 2016.11.28 | 0 |
1155 | Etc |
원어민이 매일 쓰는 일상표현 150개
![]() |
hooni | 2023.09.17 | 4885 |
1154 | Etc | 영작 연습을 위한 실용영어 문장 1001개 (1~500) | hooni | 2013.06.21 | 32069 |