Contents

Views 68124 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


?

  1. [ios] 동영상 플레이어 샘플 (for Local File)

    Date2017.02.07 CategoryDevelop Byhooni Views1213
    Read More
  2. [ios] 동영상 플레이어 샘플 (for Remote Url)

    Date2017.02.07 CategoryDevelop Byhooni Views1767
    Read More
  3. 무료로 HTTPS 적용하기 (Lets' Encrypt)

    Date2017.02.16 CategorySystem/OS Byhooni Views2393
    Read More
  4. [ios] Facebook Cache 갱신하는 함수

    Date2017.02.27 CategoryDevelop Byhooni Views1330
    Read More
  5. [ios] 동영상 플레이어 샘플 (for PIP Player)

    Date2017.03.15 CategoryDevelop Byhooni Views1410
    Read More
  6. [ios] NSString, RegularExpression Find/Replace

    Date2017.04.14 CategoryDevelop Byhooni Views961
    Read More
  7. [ios] Facebook SDK 로그인 설명

    Date2017.04.19 CategoryDevelop Byhooni Views1361
    Read More
  8. [ios] Requesting Location Permissions in iOS

    Date2018.08.18 CategoryDevelop Byhooni Views1742
    Read More
Board Pagination Prev 1 2 3 Next
/ 3