Random number generator - with from and to!

View previous topic View next topic Go down

Random number generator - with from and to!

Post by NE.CrystalBlue on Fri Feb 06, 2015 9:37 am

Hi, guys! After a bit of number-quenching and guesswork, I finally came up with my function that takes a random number from rand() and does some maths to make the from and to function work! It supports negative numbers, too. And also a mixture of negative and positive.
Here is the code:
Code:
function Random(from, to)
{
 ¬†  ¬†return (rand()*(to+1-from)) / (RAND_MAX+1)+from;
}
Purely tested.
Hope you like it!

NE.CrystalBlue
Newbie
Newbie

Posts : 2
Join date : 2015-02-01

View user profile http://vcmp.virtuaboard.com

Back to top Go down

Re: Random number generator - with from and to!

Post by NE.StrowMan on Tue Apr 14, 2015 6:12 pm

Nice Thanks for sharing

NE.StrowMan
Newbie
Newbie

Posts : 2
Join date : 2015-04-14

View user profile

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum