c++ - What other values will generate error when given to std::minstd_rand::seed()? -


i'm on vc++11, far values generate errors, not on ideone.com

#include "stdafx.h" #include <iostream> #include <random> using namespace std;   int _tmain(int argc, _tchar* argv[]) //int main(int argc, char* argv[]) {     //print_seq(seeded_rand(0x7fffffff,10));     //cout << print_seq(seeded_rand(0xffffffff,10));     ////print_seq(seeded_rand(0,10));     //cout <<  print_seq(seeded_rand(-50000,10));     //cout <<  print_seq(seeded_rand(1,10));      minstd_rand r1;     minstd_rand0 r2;      r1.seed(0);     system("pause");      return 0; } 

those values generated errors

0xfffffffe 0x7fffffff -2 0 

what other values supposed generate abort() call ?

here sceenshot

visual c++ 11.0.61030.0 update 4

26.5.3.1/5 explicit linear_congruential_engine(result_type s = default_seed); effects: constructs linear_congruential_engine object. if c mod m 0 , s mod m 0, sets engine’s state 1, otherwise sets engine’s state s mod m.

for reason, msvc implementation chooses assert in debug build when "sets engine’s state 1" condition triggers; in release build, quietly seeds 1 instead of 0.

minstd_rand typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>. seed 0 modulo 2147483647 == 0x7fffffff meaningless (the generator produce sequence of zeros, if weren't adjusting seed 1 in case).


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -