Subject: Re: BigDecimal bug?
> Can anyone tell me if this is a bug? It certainly seems like it to me.
> BigDecimal.new("-.31").to_s
> => "0.31"
Yes,could you apply the patch bellow:
---------------------------------------------------------------------------------
$ ruby/ruby-1.8.6/ext/bigdecimal
$ diff -up bigdecimal.c.old bigdecimal.c
--- bigdecimal.c.old 2007-03-14 10:21:30.015625000 +0900
+++ bigdecimal.c 2007-03-14 12:26:18.625000000 +0900
@@ -3921,7 +3921,7 @@ VpCtoV(Real *a, const char *int_chr, U_L
/* get integer part */
i = 0;
sign = 1;
- if(ni > 0) {
+ if(ni >= 0) {
if(int_chr[0] == '-') {
sign = -1;
++i;
---------------------------------------------------------------------------------
Matz, could you please apply the patch and commit the source
with the change log ?
Somewhat like:
Wed Mar 14 12:30:00 2007 Shigeo Kobayashi <>
* ext/bigdecimal/bigdecimal.c: BigDecimal("-.31") is now
treated as ("-0.31") not as ("0.31").
Thank you in advance.
Shigeo Kobayashi