1 (edited by Pragma 2016-05-29 11:38:20)

Topic: Random and string_to_number

Hello.

It seems there is a bug with random_get_state and/or random_get_state. I suspect theses functions make strange bugs in the engine.

You can test with this code.

#include "logger.bgt"

void main() {
logger log;

for (int i = 0; i < 1000; i++) {
int var = random (0, 9);
string seed = random_get_state();
random_set_state (seed);
string txt = "99";
log.add_entry ( string_to_number (txt) );
} // end for

    log.write ("log.txt", false);
} // end main

For me, until the line 614, it's OK, but after, the function string_to_number returns 0, instead of 99.