You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Matt Finn <ma...@bitcount.com> on 2003/08/26 23:17:26 UTC
NumberKey returns wrong number
Hi,
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);
}
Regards,
Matt
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org