Re: Confusion about `Random`

2022-12-22 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 22 December 2022 at 16:23:16 UTC, jwatson-CO-edu wrote: What is the reason for this? Has the compiler optimized away the `uniform` call to a single double number? What is the main difference between Program 1 and Program 2? Both seem to: * Have a global RNG `rnd` * Seed RNG after

Re: Confusion about `Random`

2022-12-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/22/22 11:23 AM, jwatson-CO-edu wrote: I am confused about why Program 1 produces random output but Program 2 does not. --- ### Program 1 ```d import std.stdio; import std.conv; import std.random; Mt19937 rnd; double rand01(){     // Uniform random sampling in [0,1)     return

Re: Confusion about `Random`

2022-12-22 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 22, 2022 at 08:17:56PM +, jwatson-CO-edu via Digitalmars-d-learn wrote: > On Thursday, 22 December 2022 at 17:33:48 UTC, Paul Backus wrote: > > So, as far as I can tell, there is nothing wrong with your code, and > > the random number generator is working as intended. > > > >

Re: Confusion about `Random`

2022-12-22 Thread jwatson-CO-edu via Digitalmars-d-learn
On Thursday, 22 December 2022 at 17:33:48 UTC, Paul Backus wrote: So, as far as I can tell, there is nothing wrong with your code, and the random number generator is working as intended. Most likely you have made a mistake somewhere in the part of the code that you did not post, and that

Re: Confusion about `Random`

2022-12-22 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 22 December 2022 at 16:23:16 UTC, jwatson-CO-edu wrote: I am confused about why Program 1 produces random output but Program 2 does not. The code you have posted as "Program 2" is incomplete, and cannot be compiled as-is. I have made some changes in order to get it to compile

Confusion about `Random`

2022-12-22 Thread jwatson-CO-edu via Digitalmars-d-learn
I am confused about why Program 1 produces random output but Program 2 does not. --- ### Program 1 ```d import std.stdio; import std.conv; import std.random; Mt19937 rnd; double rand01(){ // Uniform random sampling in [0,1) return uniform( 0.0, 1.0, rnd); } void main(){ rnd =

Re: /usr/bin/ld: [...] undefined reference to _D3std6format6internal6write...

2022-12-22 Thread Siarhei Siamashka via Digitalmars-d-learn
On Thursday, 22 December 2022 at 15:32:28 UTC, Anonymouse wrote: I'm not sure what to do. If it links on Ubuntu, but not on Manjaro/Arch, then is it possible that the GDC package from Manjaro/Arch is somehow provided with a missing, misconfigured or broken Phobos library? Maybe try to

Re: /usr/bin/ld: [...] undefined reference to _D3std6format6internal6write...

2022-12-22 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 20 December 2022 at 20:55:08 UTC, Paul Backus wrote: Apologies for the late reply. On Tuesday, 20 December 2022 at 20:01:04 UTC, Anonymouse wrote: What does `-allinst` even do `-allinst` tells the compiler to generate code for all instantiated templates, even if it thinks that