Sha256: 3aaf1abc80ad87080f6501fd416120e6c5917ebd6db2e99642dd36e1689441f2
Contents?: true
Size: 294 Bytes
Versions: 34
Compression:
Stored size: 294 Bytes
Contents
class Binary { method to_decimal ($binary) { return 0 if $binary ~~ /<-[^01]>/; my $decimal = 0; my $index = $binary.chars; for $binary.split('',:skip-empty) -> $bit { $decimal += $bit * 2 ** --$index; } return $decimal; } }
Version data entries
34 entries across 34 versions & 1 rubygems