Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6999779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:35:09+00:00 2026-05-27T20:35:09+00:00

I have been trying this for a while but thus far haven’t had any

  • 0

I have been trying this for a while but thus far haven’t had any luck.

What is the easiest way to retrieve a random number between two very precise numbers on iOS?

For example, I want a random number between 41.37783830549337 and 41.377730629131634, how would I accomplish this?

Thank you so much in advance!

Edit: I tried this:

double min = 41.37783830549337;
double max = 41.377730629131634;
double test = ((double)rand() / RAND_MAX) * (max - min) + min;
NSLog(@"Min:%lf, max:%lf, result:%lf",min,max,test);

But the results weren’t quite as precise as I was hoping, and ended up like this::

Min:41.377838, max:41.377731, result:41.377838
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:35:10+00:00Added an answer on May 27, 2026 at 8:35 pm

    You can normalise the output of rand to any range you want:

    ((double)rand() / RAND_MAX) * (max - min) + min
    

    [Note: This is pure C, I’m assuming it works equivalently in Obj-C.]

    [Note 2: Replace double with the data-type of your choice as appropriate.]

    [Note 3: Replace rand with the random-number source of your choice as appropriate.]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to do this for a while but haven't had much success.
I have been trying to fix this for a while but I have had
I have been trying to solve this problem for a while, but couldn't with
I have been trying this for a while but can't find the right solution.
I have been trying to get this working for quite a while now but
I have been trying to find a solution for this for a while but
I have been trying to code this for a while but I am so
I have been trying to find some resource on this topic for a while
Been trying to find this online for a while now. I have a SDL_Surface
I have this problem I've been trying to tackle for a while. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.