LucidDB / luciddb

DEFUNCT: See README
https://github.com/LucidDB/luciddb
Apache License 2.0
52 stars 24 forks source link

[FRG-45] decimal is sometimes returned as a double #825

Open dynamobi-build opened 12 years ago

dynamobi-build commented 12 years ago

[reporter="schoi", created="Thu, 16 Feb 2006 15:28:35 -0500 (GMT-05:00)"] I guess when S is larger, this happens; insert into a table's decimal column some value, when selecting it out, see that value represented as a double

Repro:
----------
create schema s;
set schema 's';

create table t1(a decimal(10,6) primary key);
insert into t1 values(0);
select * from t1;

--
-- +-----------+
-- | A |
-- +-----------+
-- | 0.000000 |
-- +-----------+
--


create table t2(a decimal(10,7) primary key);
insert into t2 values(0);
select * from t2;
--
-- +-------+
-- | A |
-- +-------+
-- | 0E-7 |

-- +-------+

dynamobi-build commented 12 years ago

[author="jpham", created="Thu, 16 Feb 2006 16:19:58 -0500 (GMT-05:00)"] Here is some more data:

insert into t2 values(0.0000001);
insert into t2 values(0.0000011);
select * from t2;

+------------+
| A |
+------------+
| 0E-7 |
| 1E-7 |
| 0.0000011 |
+------------+

dynamobi-build commented 12 years ago

[author="jpham", created="Thu, 16 Feb 2006 16:21:23 -0500 (GMT-05:00)"] Angel, could you help us out with this?
Do you know if this is the correct display
behavior for decimals? Thanks.

dynamobi-build commented 12 years ago

[author="jpham", created="Thu, 19 Oct 2006 15:08:10 -0500 (GMT-05:00)"] This is due to the unusual way BigDecimal.toString() works starting with Java 1.5.
The exponent notation is used if the "adjusted exponent" is less than -6.

Now the method BigDecimal.toPlainString() does what we want, i.e. print without exponent notation.
http://java.sun.com/j2se/1.5.0/docs/api/