Sha256: a0ba91b4960241395da296113aaa7d192a82d1da2b09139ebe0c2ad81004b7bc

Contents?: true

Size: 564 Bytes

Versions: 39

Compression:

Stored size: 564 Bytes

Contents

#include "xot/util.h"


#include <stdlib.h>


namespace Xot
{


	int
	bit2byte (int bits)
	{
		if ((bits % 8) != 0) return -1;
		return bits / 8;
	}

	int
	byte2bit (int bytes)
	{
		return bytes * 8;
	}


	static bool seeded = false;

	void
	seed (uint value)
	{
		srand(value);
		seeded = true;
	}

	double
	random (double max_)
	{
		return random(0, max_);
	}

	double
	random (double min_, double max_)
	{
		if (!seeded) seed();

		double n = (double) rand() / (double) RAND_MAX;
		if (max_ != 1) n *= max_;
		if (min_ != 0) n += min_;
		return n;
	}


}// Xot

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
xot-0.3.3 src/util.cpp
xot-0.3.2 src/util.cpp
xot-0.3.1 src/util.cpp
xot-0.3 src/util.cpp
xot-0.2.1 src/util.cpp
xot-0.2 src/util.cpp
xot-0.1.42 src/util.cpp
xot-0.1.41 src/util.cpp
xot-0.1.40 src/util.cpp
xot-0.1.39 src/util.cpp
xot-0.1.38 src/util.cpp
xot-0.1.37 src/util.cpp
xot-0.1.36 src/util.cpp
xot-0.1.35 src/util.cpp
xot-0.1.34 src/util.cpp
xot-0.1.33 src/util.cpp
xot-0.1.32 src/util.cpp
xot-0.1.31 src/util.cpp
xot-0.1.30 src/util.cpp
xot-0.1.29 src/util.cpp