New answers tagged

0

Utilize subtraction and booleans in comparisons If you are in need of an operation like -ne and -gt and you are counting down, you can use the subtraction operator, -, instead of using an extra two bytes Example: for($i=40;$i-10;$i--){$i} # 40...11 for($i=40;$i-gt10;$i--){$i} # 40.....


4

Use [bigint] instead of [Math]::floor The bigint datatype is a numeric type that can store arbitrarily large numbers and holds no decimal values. It always floors when using [bigint]::new(). A suffix for it was added in PowerShell core but using the n prefix rounds normally instead of floor which doesn't work for this. Example: [bigint](.9) # 0 [...


Top 50 recent answers are included