mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-24 08:37:11 +02:00
misc: Convert UIntUtils.CreateRandom into an extension on Random.
This commit is contained in:
parent
cb31d79164
commit
a989d28e03
5 changed files with 14 additions and 12 deletions
|
@ -5,14 +5,16 @@ namespace Ryujinx.Common.Utilities
|
|||
{
|
||||
public static class UInt128Utils
|
||||
{
|
||||
public static UInt128 FromHex(string hex)
|
||||
{
|
||||
return new UInt128(ulong.Parse(hex.AsSpan(0, 16), NumberStyles.HexNumber), ulong.Parse(hex.AsSpan(16), NumberStyles.HexNumber));
|
||||
}
|
||||
public static UInt128 FromHex(string hex) =>
|
||||
new(
|
||||
ulong.Parse(hex.AsSpan(0, 16), NumberStyles.HexNumber),
|
||||
ulong.Parse(hex.AsSpan(16), NumberStyles.HexNumber)
|
||||
);
|
||||
|
||||
public static UInt128 CreateRandom()
|
||||
{
|
||||
return new UInt128((ulong)Random.Shared.NextInt64(), (ulong)Random.Shared.NextInt64());
|
||||
}
|
||||
public static Int128 NextInt128(this Random rand) =>
|
||||
new((ulong)rand.NextInt64(), (ulong)rand.NextInt64());
|
||||
|
||||
public static UInt128 NextUInt128(this Random rand) =>
|
||||
new((ulong)rand.NextInt64(), (ulong)rand.NextInt64());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue