Favor to ask of Linux/Unix users

Hello,

I'm trying to port some pseudo-random number generating functions from Linux/Unix's <stdlib.h> to windows. It seems to be working all right, but I'd like to know if the numbers I'm generating are the same on the original platform - given the same seed(s).

So, if there are any Linux/Unix users out there, and you'd like to help me with this little experiment, compile the following program and let me know which values are printed for the following seeds:

0
1
2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <stdlib.h>

int main(int argc, char* argv[]) {

	long seed = 0;
	//long seed = 1;
	//long seed = 2;
	srand48(seed);

	std::cout << lrand48() << std::endl;

	std::cin.get();
	return 0;

}



Here are the values I'm getting:

seed 0: 366850414
seed 1: 89400484
seed 2: 1959434203

Last edited on
same on a mac
Thank you, sir!

By the way, I'm still all ears if anyone else has some input.
Last edited on
I'm on my mobile right now so I couldn't do it myself ,although you can do it yourself using any of online compilers available :coliru.stacked-crooked.com , code pad, ideone ... they all use GCC .
Same output on Linux Ubuntu 12.04
Why do you want to know this?
xismn wrote:
Why do you want to know this?

He said why... because he's porting it and he wants to know if the port is accurate.
@ a k n, thanks for suggesting online compilers, somehow I hadn't considered them!

Thanks to everyone else as well - your input is appreciated!
Topic archived. No new replies allowed.