简体   繁体   中英

how to handle floating-point in cratedb

floating-point

When doing math operation in cratedb, it produces floating point, here is how I create table in crate:

create table:

create table cash(date string, spend float);
insert into cash(date, spend) values ('2017-05-03', 55.55);
insert into cash(date, spend) values ('2017-05-03', 34.55);
insert into cash(date, spend) values ('2017-05-03', 87.55);
select (0 - spend) sp,* from cash limit 100;

the picture above is the result of executing the select sql

dataTypes in cratedb have no support for decimal, do you have any suggestions on handling this issue in cratedb?

thanks

Thanks for reporting this. We fixed this issue already and it has also been released with CrateDB 1.1.3 (stable).

As a side note:
This improvement checks if an expression consisting of an arithmetic operator and a decimal value only contains float types. If this is the case the resulting data type will be of type float . In case the expression contains decimal values of type double the behavior is like before and the result type will also be a representation of type double .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM