in reply to Boolean calculation incorrect values
The Perl ~ operator performs bitwise negation. As you say you’re expecting a result of 1 (and not -1), I think you’re looking for logical negation:
17:58 >perl -wE "printf '%b', (~0b0 & ~0b0);" 1111111111111111111111111111111111111111111111111111111111111111 18:00 >perl -wE "printf '%b', (!0b0 & !0b0);" 1 18:01 >
See perlop#Symbolic-Unary-Operators.
Update: Added the underlined clause.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Boolean calculation incorrect values
by GrandFather (Saint) on Dec 24, 2015 at 08:28 UTC | |
by Athanasius (Archbishop) on Dec 24, 2015 at 08:58 UTC |