Results for “Numbers & numeric validation”
Small, practical examples. Search by task or narrow things down below.
Pad a numeric label to a fixed width
C#: Use a numeric format specifier to add leading zeroes.
C#✓ Tested
Reject NaN and infinite numeric inputs
Python: Use isfinite before computations that require an ordinary finite float.
Python✓ Tested
Reject non-finite numeric input
Reject non-finite numeric input using a complete Go program with explicit sample inputs.
Go✓ Tested
Clamp a number to inclusive bounds
PowerShell: Math.Clamp chooses the nearest endpoint for an out-of-range value.
PowerShell✓ Tested
Compute beyond the fixed-width integer range
PowerShell: BigInteger keeps an exact result when ordinary integer types are too small.
PowerShell✓ Tested
Convert Unix seconds into an aware UTC timestamp
PowerShell: DateTimeOffset.FromUnixTimeSeconds creates a value with an explicit UTC offset.
PowerShell✓ Tested
Count days between calendar dates
PowerShell: Parse an unambiguous format before subtracting date values.
PowerShell✓ Tested
Find the number of days in a month
PowerShell: DaysInMonth handles leap-year February correctly.
PowerShell✓ Tested
Format a bounded duration as hours minutes and seconds
PowerShell: TimeSpan can format duration components with escaped separators.
PowerShell✓ Tested
Parse a hexadecimal integer
PowerShell: Convert.ToInt32 accepts an explicit base for a validated hexadecimal string.
PowerShell✓ Tested
Parse an integer without throwing on invalid input
PowerShell: TryParse reports conversion success separately from its output value.
PowerShell✓ Tested
Reject NaN and infinite values
PowerShell: Double.IsFinite excludes numeric values unsuitable for ordinary bounded calculations.
PowerShell✓ Tested