gd_core/addons/core/math/Rand.cs

33 lines
683 B
C#

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// D E R E L I C T
//
/// // (c) 2003..2025
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
//namespace client.addons.core.math;
// No namespace, just directly access rand
static public class rand
{
static ThreadLocal<Random> s_rand = new( () => new Random() );
static rand()
{
}
const int c_bitForBinary = 1 << 24;
static public double unit() => s_rand.Value.NextDouble();
static public bool binary() => ( s_rand.Value.NextInt64() & c_bitForBinary ) != 0;
}