db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Finn <li...@bitcount.com>
Subject NumberKey returns wrong number
Date Tue, 26 Aug 2003 21:22:03 GMT

I've been having problems with the NumberKey(long) constructor.

The following statement outputs "9900000000000000":
  System.out.println((new NumberKey(9900000000000001L)).toString());

This is because NumberKey(long) uses the BigDecimal(double)
constructor and introduces floating point errors:

The constructor should use the valueOf(long) static factory method 
to avoid the conversion errors.

     public NumberKey(long key)
-        this.key = new BigDecimal(key);
+        this.key = BigDecimal.valueOf(key);



To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org

View raw message