mbbsemu / MBBSEmu

The MajorBBS Emulation Project is an Open Source, Cross-Platform emulator for easily running The MajorBBS & Worldgroup Modules
https://www.mbbsemu.com
MIT License
126 stars 14 forks source link

Update RNG to use Borland C++ RNG Routine #579

Closed enusbaum closed 11 months ago

enusbaum commented 11 months ago
enusbaum commented 11 months ago

Verified against Borland C++ 4.5

Compiled the following using bcc rand.cpp:

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

int main() {
    // Seed the random number generator
    srand(1234);

    // Generate and output the next three random numbers
    for (int i = 0; i < 10; ++i) {
        int randomNum = rand();
        printf("Random number %d: %d\n", (i + 1), randomNum);
    }

    return 0;
}

Output Results:

image

Unit Tests for rand() are verified against this list

enusbaum commented 11 months ago

Verified it's the same stdlib routine embedded within majorbbs.exe:

image