Logo

Programming-Idioms

  • Go

Idiom #251 Parse binary digits

Extract integer value i from its binary string representation s (in radix 2)
E.g. "1101" -> 13

import "strconv"
i, err := strconv.ParseInt(s, 2, 0)

i has type int64
(def i (read-string (str "2r" s)))

New implementation...