Timeline for Generate any random integer
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 28, 2014 at 20:09 | comment | added | GiantTree | Well, that's another way of doing it. | |
Dec 28, 2014 at 20:07 | comment | added | Peter Cordes | Hobbs and I both posted perl solutions that print a digit at a time. (His prints leading zeros, mine doesn't). This sidesteps and memory and BigInt problems. | |
Dec 26, 2014 at 16:19 | history | edited | Timtech | CC BY-SA 3.0 |
removed unneccessary line breaks
|
Dec 26, 2014 at 2:29 | history | edited | GiantTree | CC BY-SA 3.0 |
added 1021 characters in body
|
Dec 26, 2014 at 1:53 | comment | added | GiantTree |
@MartinBüttner Both are possible but eg. the string would overflow after 2gb of data making it finite again. It's hard to say that a number should be infinitely large if there are issues with memory. I'll come up with a different approach soon using BigInts. Also the integer does not overflow at 1.7e308 it just gets converted to infite (1.#INF to be exact)
|
|
Dec 26, 2014 at 1:46 | comment | added | GiantTree | @MartinBüttner I tried my best to meet the spec of the question. It's just not possible for me (at least not without help) to generate infinitely large integers. Perl's largest integer is about 1.7e308 which is a limit I cannot control. | |
Dec 26, 2014 at 1:26 | history | edited | GiantTree | CC BY-SA 3.0 |
added 146 characters in body
|
Dec 26, 2014 at 1:14 | comment | added | GiantTree | I just saw that that ridiculously big integer has to be generated as well. I'll edit my code quickly. | |
Dec 26, 2014 at 1:12 | comment | added | GiantTree |
@Optimizer for me an integer is defined as in many programming languages: a number within the bounds of -2^31 and +2^31-1 (32bits). You can easily increase the exponents if you'd like to generate larger integers but it may fail depending on the implementation of Perl.
|
|
Dec 26, 2014 at 1:06 | comment | added | Optimizer | Didn't we agree that there should not be any upper/lower bounds ? For instance, the integer 2^31 + 1 has 0 probability, breaking rule 2 | |
Dec 26, 2014 at 1:04 | history | answered | GiantTree | CC BY-SA 3.0 |