BitwiseShiftRightTest
`Bitwise.shiftRightBy` is an arithmetic shift: it divides a positive number by a power of two, and keeps the sign of a negative one, so `-1` shifted right stays `-1`.
Results
elm-0.19.1
passran in 73 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. shr1: 1 shr2: 8 shr3: -1
elm-0.19.2
passran in 52 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. shr1: 1 shr2: 8 shr3: -1
elm-0.19.3
passran in 67 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. shr1: 1 shr2: 8 shr3: -1
lamdera-1.5.0
passran in 47 msOutput
shr1: 1 shr2: 8 shr3: -1
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/BitwiseShiftRightTest] in its title.
Source
The -- CHECK: lines give the expected output.
module BitwiseShiftRightTest exposing (main)
{-| `Bitwise.shiftRightBy` is an arithmetic shift: it divides a positive number by a power of two, and keeps the sign of a negative one, so `-1` shifted right stays `-1`.
-}
-- CHECK: shr1: 1
-- CHECK: shr2: 8
-- CHECK: shr3: -1
import Bitwise
import Html exposing (text)
main =
let
_ = Debug.log "shr1" (Bitwise.shiftRightBy 4 16)
_ = Debug.log "shr2" (Bitwise.shiftRightBy 1 16)
_ = Debug.log "shr3" (Bitwise.shiftRightBy 4 -1)
in
text "done"