Post: [C++] best Random Number
03-17-2013, 10:57 PM #1
SC-Wotan
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({});
    int   result;

time_t timestamp; // Timestamp of type time_t
tm *nun; // We need a variable of the structure tm to access the individual member

// Calculation of the algorithm //

timestamp = time( 0 ); // Total number of seconds since 1979 !
nun = localtime( &timestamp ); // Calculation of the current time by the total number of seconds
result = 1000;
result = nun->tm_sec / 3; // first calculation of the algorithm

while( result > 3 ){

result/=3; // calculated it until result is a maximum of 3 !

// 3 is only a Example !!! //

}
Last edited by SC-Wotan ; 03-17-2013 at 11:00 PM.
03-17-2013, 11:39 PM #2
Pichu
RIP PICHU.
    [COLOR=#FF8000][FONT=monospace]// Total number of seconds since 1979 !


​Um What?
[/FONT][/COLOR]
03-17-2013, 11:59 PM #3
SC-Wotan
Do a barrel roll!
the number of seconds from 1967 to today
03-18-2013, 04:33 AM #4
Izl
Do a barrel roll!
how is this the best random number gen?
03-18-2013, 04:17 PM #5
Sloth
Banned
Originally posted by Wotan View Post
    int   result;

time_t timestamp; // Timestamp of type time_t
tm *nun; // We need a variable of the structure tm to access the individual member

// Calculation of the algorithm //

timestamp = time( 0 ); // Total number of seconds since 1979 !
nun = localtime( &timestamp ); // Calculation of the current time by the total number of seconds
result = 1000;
result = nun->tm_sec / 3; // first calculation of the algorithm

while( result > 3 ){

result/=3; // calculated it until result is a maximum of 3 !

// 3 is only a Example !!! //

}

This looks nice well done.

Originally posted by Izl View Post
how is this the best random number gen?

There are many way in which this could be the best e.g. it could be the best optimized RNG or it could be the best looking RNG.

I really dislike it when people don't give either thanks or constructive criticism to other peoples creations or even just a simple Well Done.

I do like your other posts though they were quite helpful and nice.
You should know this already but: "If you do not have anything nice to say don't say anything at all"
Last edited by Sloth ; 03-19-2013 at 03:47 PM.

The following user thanked Sloth for this useful post:

Pichu
03-28-2013, 02:21 AM #6
Originally posted by Wotan View Post
    int   result;

time_t timestamp; // Timestamp of type time_t
tm *nun; // We need a variable of the structure tm to access the individual member

// Calculation of the algorithm //

timestamp = time( 0 ); // Total number of seconds since 1979 !
nun = localtime( &timestamp ); // Calculation of the current time by the total number of seconds
result = 1000;
result = nun->tm_sec / 3; // first calculation of the algorithm

while( result > 3 ){

result/=3; // calculated it until result is a maximum of 3 !

// 3 is only a Example !!! //

}


ehh I wouldn't say it's the best. You would want something with primes, and mod's so you could have a min and max. Also RSA can be used for random numbers and is proven to be more effective although you will fail on the speed side.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo