Skip to content

Commit

Permalink
fix BigDecimal.new starting with underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
calavera committed Jul 23, 2010
1 parent b40a551 commit 403f943
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/org/jruby/RubyBigDecimal.java
Expand Up @@ -383,7 +383,10 @@ public static RubyBigDecimal newInstance(IRubyObject recv, IRubyObject[] args) {
// by Java's BigDecimal. Not terribly efficient for now.
// 1. MRI allows d and D as exponent separators
strValue = strValue.replaceFirst("[dD]", "E");
// 2. MRI allows underscores anywhere
// 2. MRI allows underscores anywhere but in the beginning
if (strValue.startsWith("_")) {
return newZero(runtime, 1);
}
strValue = strValue.replaceAll("_", "");
// 3. MRI ignores the trailing junk
strValue = NUMBER_PATTERN.matcher(strValue).replaceFirst("$1");
Expand Down

0 comments on commit 403f943

Please sign in to comment.