Contents

조회 수 78021 댓글 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


?

  1. [c] 파일(int fd)에서 개행문자 단위로 읽기 by 후리자

  2. [c] 파일명 또는 특정 패턴을 적용

  3. [c] 파일입출력 간단한 설명

  4. [c] 파일입출력, 링크리스트(linked list)를 이용한 주소록(도스용) 소스코드

  5. [c] 패스워드 암호화/사용자 정보 보기

  6. [c] 패킷 에널라이저 예제 소스(성안당)

  7. [c] 패킷 유량/프로토콜 통계 모니터링..

  8. [c] 패킷정보출력(경로, 패킷길이, 3hand, sync, ack..)

  9. [c] 팩토리얼 서버/클라이언트..

  10. [c] 팩토리얼.. - 재귀함수

  11. [c] 포인터 학습용 예제 소스 코드

  12. [c] 포인터와 함수포인터에 대해..

Board Pagination Prev 1 ... 29 30 31 32 33 34 35 36 37 38 ... 99 Next
/ 99