Last active
April 18, 2017 14:11
-
-
Save 9999years/4bf2972eca0c10e4e9f7e6afe0a92571 to your computer and use it in GitHub Desktop.
Wrapper functions to make Powershell’s [System.Math]::Method()s easier to use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# math functions | |
# wrappers to make [System.Math]::Method()s easier to use | |
[double]$global:PI = 3.14159265358979323846 | |
[double]$global:E = 2.71828182845904523536 | |
function abs { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::abs($a) | |
} | |
} | |
function acos { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::acos($a) | |
} | |
} | |
function asin { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::asin($a) | |
} | |
} | |
function atan { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::atan($a) | |
} | |
} | |
function atan2 { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::atan2($a) | |
} | |
} | |
function bigMul { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][int]$a, [int]$b) | |
Process { | |
[Math]::bigMul($a, $b) | |
} | |
} | |
function ceiling { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::ceiling($a) | |
} | |
} | |
function cos { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::cos($a) | |
} | |
} | |
function cosh { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::cosh($a) | |
} | |
} | |
function divRem { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a, [double]$b) | |
Process { | |
$result = 0 | |
[Math]::divRem($a, $b, [ref]$result) > $Null | |
return $result | |
} | |
} | |
function equals { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a, [double]$b) | |
Process { | |
[Math]::equals($a, $b) | |
} | |
} | |
function exp { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::exp($a) | |
} | |
} | |
function floor { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::floor($a) | |
} | |
} | |
function IEEERemainder { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a, [double]$b) | |
Process { | |
[Math]::IEEERemainder($a, $b) | |
} | |
} | |
function log { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::log($a) | |
} | |
} | |
function log10 { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::log10($a) | |
} | |
} | |
function max { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::max($a) | |
} | |
} | |
function min { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::min($a) | |
} | |
} | |
function pow { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a, [double]$b) | |
Process { | |
[Math]::pow($a, $b) | |
} | |
} | |
function round { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::round($a) | |
} | |
} | |
function sign { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::sign($a) | |
} | |
} | |
function sin { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::sin($a) | |
} | |
} | |
function sinh { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::sinh($a) | |
} | |
} | |
function sqrt { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::sqrt($a) | |
} | |
} | |
function tan { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::tan($a) | |
} | |
} | |
function tanh { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::tanh($a) | |
} | |
} | |
function truncate { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline = $True)][double]$a) | |
Process { | |
[Math]::truncate($a) | |
} | |
} | |
New-Alias trunc truncate -ErrorAction SilentlyContinue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment