using System;
using Cosmos.Common.Extensions;
namespace Cosmos.Common
{
///
/// Helper class for working with numbers.
///
public static class NumberHelper
{
///
/// Write number to console.
///
/// A value to print.
/// A value indicating whether strarting zeros should be present.
public static void WriteNumber(uint aValue, bool aZeroFill)
{
WriteNumber(aValue, 32, aZeroFill);
}
///
/// Write number to console.
///
/// A value to print.
/// Count of bits to display.
public static void WriteNumber(uint aValue, int aBits)
{
WriteNumber(aValue, aBits, true);
}
///
/// Write number to console.
///
/// A value to print.
/// Count of bits to display.
/// A value indicating whether strarting zeros should be present.
public static void WriteNumber(uint aValue, int aBits, bool aZeroFill)
{
if (aZeroFill)
{
Console.WriteLine("0x" + aValue.ToHex(aBits / 4));
}
else
{
Console.WriteLine("0x" + aValue.ToHex(aBits / 4).TrimStart('0'));
}
}
}
}