Private/isNumeric.ps1
|
<#
.SYNOPSIS Test whether a value is a numeric type. .DESCRIPTION Returns `$true` if the input value is any .NET numeric type (byte, int16, int32, int64, sbyte, uint16, uint32, uint64, float, double, or decimal). .PARAMETER x The value to test. Accepts pipeline input. .EXAMPLE PS> 42 | isNumeric Returns $true. #> function isNumeric { param( [Parameter(ValueFromPipeline)] $x ) process { return $x -is [byte] -or $x -is [int16] -or $x -is [int32] -or $x -is [int64] -or $x -is [sbyte] -or $x -is [uint16] -or $x -is [uint32] -or $x -is [uint64] -or $x -is [float] -or $x -is [double] -or $x -is [decimal] } } |