db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@debrunners.com>
Subject Re: Format of getString() for DECIMAL type?
Date Mon, 22 Nov 2004 17:51:21 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jeremy Boynes wrote:

> When getString() is called on a DECIMAL value, Derby implements this by
> calling toString() on the underlying BigDecimal object (in
> SQLDecimal.getString()).
>
> However, with JDK1.5 the format of the text returned from toString() has
> changed; see:
>
http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html#toString()
>
>
http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#toString()
>
>
http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#toPlainString()
>
>
> When running under JDK1.5, should use the VM's native formatting or have
> a custom formatter that uses the representation from JDK1.4 and earlier
> (perhaps by calling toPlainString())?
>
> If we stick with the native conversion, behaviour will be consistent
> with BigDecimal.toString() on any given platform but may vary between
> pre- and post- JDK1.5 VMs. If we stick with the old format then the
> output from Derby will remain consistent between platforms but on a
> JDK1.5 platform will differ from BigDecimal.toString() which may be
> surprising to users.

The SQL standard says that for a cast from an exact numeric (DECIMAL) to
a character string, the format of the string must match the literal
format for the exact numeric. The SQL format of the exact numeric
literal does not support exponent notation (E). Thus I think DECIMAL
should use toPlainString() for J2SE 5.0.

As in an earlier thread, I need to split the Decimal behaviour out into
two or three implementations for J2ME, J2SE (1.3,1.4) and J2SE 5.0.

Dan.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBoicZIv0S4qsbfuQRAkrNAJ9WbNM3R+WguANafpqNnLk2rkNQQACgsJmr
9P96hghU65uSjdHuF9H9mFU=
=GrT9
-----END PGP SIGNATURE-----


Mime
View raw message