Arithmetic/Integer: Difference between revisions

Content added Content deleted
(Add Bash example)
Line 1,112: Line 1,112:
Write-Host "Product: $($a * $b)"
Write-Host "Product: $($a * $b)"
Write-Host "Quotient: $($a / $b)"
Write-Host "Quotient: $($a / $b)"
Write-Host "Quotient, explicitly rounded: $([Math]::Round($a / $b))"
Write-Host "Quotient, round to even: $([Math]::Round($a / $b))"
Write-Host "Remainder: $($a % $b)"</lang>
Write-Host "Remainder, sign follows first: $($a % $b)"</lang>
Numbers are automatically converted to accomodate for the result. This means not only that Int32 will be expanded to Int64 but also that a non-integer quotient will cause the result to be of a floating-point type.
Numbers are automatically converted to accomodate for the result. This means not only that Int32 will be expanded to Int64 but also that a non-integer quotient will cause the result to be of a floating-point type.