1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00
ZoKrates/zokrates_stdlib/stdlib/utils/casts/u16_to_field.zok
2020-11-12 11:01:33 +00:00

10 lines
No EOL
232 B
Text

import "EMBED/u16_to_bits" as to_bits
def main(u16 i) -> field:
bool[16] bits = to_bits(i)
field res = 0
for u32 j in 0..16 do
u32 exponent = 16 - j - 1
res = res + if bits[j] then 2 ** exponent else 0 fi
endfor
return res