Function: FRandom
Function: FRandom

Function: FRandom

FRandom ( )

Returns a random positive floating-point value up to, but not including, 1.0.

Parameters

No Parameters

Returns

VALUE(FLOAT) A random floating-point value.

What It Does

This function returns a random floating-point value from 0.0 up to (but not including) 1.0.

Example

NOTE: The following code will return different values every time it is executed!

Random Function Examples


world
{
	start()
	{
		local a;
		a = 10;
		textln("Generating " + a + " integers from 0 to 9:");
		while (a > 0)
		{
			textln(irandom(10));
			a = a - 1;
		}
		textln("");

		a = 10;
		textln("Generating " + a + " floats from [0.0, 1.0):");
		while (a > 0)
		{
			textln(frandom());
			a = a - 1;
		}
		textln("");

		a = 10;
		textln("Generating " + a + " Gaussian floats, mean 0, std. dev. 1:");
		while (a > 0)
		{
			textln(grandom(0, 1));
			a = a - 1;
		}
		
		quit;
	}
}

See Also

IRandom() — Returns a random integer value.
GRandom() — Returns a random floating-point value with Gaussian distribution.

Additional Technical Notes

Authors can expect the distribution of this random number generator to be uniform.

The method of generating random numbers is up to the TAME implementation (Java, JS, etc.), and the generator has not been standardized, yet.

There is currently no way to seed the random number generator for testing purposes, at the time of this writing.

×

Modal Header