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 8771719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:51:40+00:00 2026-06-13T17:51:40+00:00

About random.uniform , docstring says: Get a random number in the range [a, b)

  • 0

About random.uniform, docstring says:

Get a random number in the range [a, b) or [a, b] depending on rounding.

But I do not know what does ‘depending on rounding’ exactly mean.

  • 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-06-13T17:51:41+00:00Added an answer on June 13, 2026 at 5:51 pm

    The current documentation for random.uniform() reads:

    Return a random floating point number N such that a <= N <= b for a <= b and b <= N <= a for b < a.

    The end-point value b may or may not be included in the range depending on floating-point rounding in the equation a + (b-a) * random().

    Floating point arithmetic on computers is limited in precision and rounding errors caused by this imprecision may lead to b not being included in the full range of values used for the random value that uniform() returns.

    random.random() returns a value between 0.0 (inclusive) and 1.0 (exclusive). There are values for a and b where a floating point calculation of the sum a + (b-a) * (1.0 - epsilon/2) does not equal b, but will be a minute amount lower than b, while for other combinations the sum does equal to b. epsilon is the minimum precision of a floating point number on your platform (see sys.float_info), and 1.0 - epsilon/2 the maximum value random.random() can return.

    If you are interested in the details of why floating point arithmetic on computers is imprecise, I can recommend the following two articles:

    • The Floating Point Guide
    • What Every Computer Scientist Should Know About Floating-Point Arithmetic
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are another questions about random in a range but none of
I know how to select one random item from an array, but how about
I know there have been several posts about random word generation based on large
I just read this interesting question about a random number generator that never generates
here are the 5 lines trying to get informations about some random PDF: MonoTouch.CoreGraphics.CGPDFDocument
I need to generate about 5,000 random numbers in my script, but the CPU
How would I go about creating a random number generator which has a bias
I'd like to get uniform distribution in range [0.0, 1.0) If possible, please let
The problem is not about randomness itself (we have rand), but in cryptographically secure
I know how to show number random using this code below from 0 to

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.