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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:16:28+00:00 2026-05-18T04:16:28+00:00

I want to produce a natural number (a positive integer between 0 and x)

  • 0

I want to produce a natural number (a positive integer between 0 and x) by using lcg_value(). This is what I can see from the actual source code for the function:

/*
 * combinedLCG() returns a pseudo random number in the range of (0, 1).
 * The function combines two CGs with periods of
 * 2^31 - 85 and 2^31 - 249. The period of this function
 * is equal to the product of both primes.
 */

Now, how would I turn that float into a natural number so that I do not lose information/entropy. Currently I just do it like this:

$number = pow(2,31) * lcg_value();

However, I have a feeling in my gut that it’s not perfect. How about 2^62? Or perhaps 2^31-334? Or 2^62-334? I don’t know.

  • 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-18T04:16:28+00:00Added an answer on May 18, 2026 at 4:16 am

    either type float or int are bounded by platform

    Integer The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that’s 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18. PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5.

    float The size of a float is platform-dependent, although a maximum of ~1.8e308 with a precision of roughly 14 decimal digits is a common value (the 64 bit IEEE format).

    to maintain highest precision of float, u can refer http://www.php.net/manual/en/function.bcmul.php

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

Sidebar

Related Questions

I want to produce sounds/beeps from my sound card using Python. Is it possible?
I want to produce histograms using by(), how can I access the values of
I want to produce a list of all of the labels using the command
I have a on memory Datatable like this. I want to produce xml file
I want to compile GCC and binutils which would produce 64bit executables. From GNU
I want to override the default integer constructors in Haskell so they produce strings
I'm trying to produce a line chart using Flot, but I want the data
Consider the following directory structure: ./source/com/mypackage/../A.java ./extensions/extension1/source/com/mypackage/../T.java ./extensions/extension2/source/com/mypackage/../U.java ... ./extensions/extensionN/source/com/mypackage/../Z.java I want to produce
I want to produce a list of numbers from 1 to 5 incrementing by
I want to produce an HTML file like this example: English En Lorem ipsum

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.