vm: implement BigInt -> Boolean conversion

This commit is contained in:
Evgenii Stratonikov 2019-09-10 14:19:36 +03:00
parent 33bb371f9b
commit 52b0d661e0

View file

@ -63,6 +63,11 @@ func (e *Element) BigInt() *big.Int {
switch t := e.value.(type) {
case *BigIntegerItem:
return t.value
case *BoolItem:
if t.value {
return big.NewInt(1)
}
return big.NewInt(0)
default:
b := t.Value().([]uint8)
return new(big.Int).SetBytes(util.ArrayReverse(b))