• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Generate Random numbers between 0 and 4
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generate Random numbers between 0 and 4


  • Subject: Re: Generate Random numbers between 0 and 4
  • From: Matt Gough <email@hidden>
  • Date: Tue, 23 Dec 2003 13:36:59 +0000

>> How can I generate Random Numbers between 0 and 4?
>>
>> With the function short Random() is it possible?
>
> int n = (Random() % 4);

For numbers between 0 and 4 inclusive then it should be % 5, not % 4.

However the specification of 'Numbers between 0 and 4' is a bit vague, as he
might only want 1, 2 and 3. As is often the case on the developer lists,
people ask vague questions :/

Matt
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Generate Random numbers between 0 and 4
      • From: Usama Minegishi <email@hidden>
References: 
 >Re: Generate Random numbers between 0 and 4 (From: Sailor Quasar <email@hidden>)

  • Prev by Date: [ANN] PreFab UI Browser pricing change
  • Next by Date: Re: Database Application with Obj-C
  • Previous by thread: Re: Generate Random numbers between 0 and 4
  • Next by thread: Re: Generate Random numbers between 0 and 4
  • Index(es):
    • Date
    • Thread