Permalink
Browse files

implement :60[..] with decimal dot

  • Loading branch information...
moritz committed Sep 30, 2012
1 parent 8365f1b commit 30a13c1189626efb4af04d03d8c8f8841cd2f6ac
Showing with 14 additions and 1 deletion.
  1. +1 −0 docs/ChangeLog
  2. +13 −1 src/core/Str.pm
View
@@ -4,6 +4,7 @@ New in 2012.09.1
+ binding to signatures in declarators
+ the is hidden and base traits
+ ability to set encoding on sockets temporarily removed (reverts to 2012.08 behavior)
++ :60[24, 59, 59] radix form
New in 2012.09
+ class Iterable does not inherit from class Cool anymore
View
@@ -1085,8 +1085,20 @@ sub unbase(Int:D $base, Str:D $str) returns Numeric:D {
# for :16[1, 2, 3]
sub unbase_bracket($base, @a) {
my $v = 0;
+ my $denom = 1;
+ my Bool $seen-dot = False;
for @a {
- $v = $v * $base + $_;
+ if $seen-dot {
+ die "Only one decimal dot allowed" if $_ eq '.';
+ $denom *= $base;
+ $v += $_ / $denom
+ }
+ elsif $_ eq '.' {
+ $seen-dot = True;
+ }
+ else {
+ $v = $v * $base + $_;
+ }
}
$v;
}

0 comments on commit 30a13c1

Please sign in to comment.