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

  • Home
  • SEARCH
  • 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 6015009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:46:27+00:00 2026-05-23T02:46:27+00:00

Let say that I would like to get an random double value wich is:

  • 0

Let say that I would like to get an random double value wich is:

  1. greater than -0.150
  2. less than +0.150
  3. most close to 0.440

This number must be random…

How can I do that?


Additional info:

Like you said… 0.440 is not in [-0.150, 0.150], but I need to generate an number close to that number in this range…

let say that I call:

getMyRandomNumber(-0.150, 0.150, 0.440)

I would like to get an number in the range [-0.150, 0.150] but that it isn’t allways 0.150

I would like to get numbers like 0.139, 0.140, 0.121,…

If I call:

getMyRandomNumber(-0.150, 0.150, -0.440)

I would like to get numbers like -0.139, -0.140, -0.121,…

  • 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-23T02:46:28+00:00Added an answer on May 23, 2026 at 2:46 am

    Random’s NextDouble() returns a random number between 0.0 and 1.0

    If you want to get a random number in the interval (a, b) based on the random number from NextDouble() then you need to map the (0.0, 1.0) interval you get to the (a, b) interval you need.

    The simplest way is to use this formula:
    result = a + (b - a) * X
    where X is the result from NextDouble()

    If X is 0 then result will be a, if X is 1 then result will be b, for X between 0.0 and 1.0 the result will be between a and b.

    If you want numbers close to a certain number (say 0.44) but no further than 0.15 away then you need to map the results into the (0.44 – 0.15, 0.44 + 0.15) interval.

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

Sidebar

Related Questions

Let's say I have a list of domain names that I would like to
Let's say that if I read from www.example.com/number, I get a random number. In
Let's say that I have string: -dog--cat--d-- I would like to find all words
Let's say I have a string that I would like to obfuscate in my
Let's say that accounts in my SAAS are of the type Account(models.Model) . Would
Let's say I have a class like this (and also further assume that all
I have a single text area input that I would like to get as
Let's say that in the controller I get an array of objects from the
Let say that I have a website with some information that could be access
Let say that we have the following query: SELECT DISTINCT COUNT(`users_id`) FROM `users_table`; this

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.