No match found for function signature Round(<NUMERIC>, <NUMERIC>)


#1

The documentation shows that:

ROUND(x, y) rounds x to y decimal places

but I can’t get to use this function because the error in object.

I am using MapD 3.1.1 , is someone successful using this function?


#2

nope it works with only one argument rounding the integer part of the float; you can try the trucate function but it’s bugged ttoo


#3

Hi,

The documentation is incorrect the round(x) function takes a single parameter.

There is a new function in the next release called round_to_digit(x,y) which will behave as you want.

We will get the docs updated, thanks for the notification.

@aznable what is the issue you see when you use the truncate function. It is not designed to round, just trim.

regards


#4

this one

select truncate(lat,2) from airports limit 10;
42.370003
37.640003
41.700005
41.500004
43.770004
39.140003
39.090004
63.880005
25.790003
48.410004

the last digit would be 0.


#5

Hi @aznable

What you are seeing here is the standard imprecision of float or double numeric representation.

regards


#6

maybe i am misinterpreting the truncate function.

another example:
mapdql> create table test (amount float);
mapdql> insert into test (amount) values (12.92);
Execution time: 51 ms, Total time: 52 ms
mapdql> insert into test (amount) values (8.41);
Execution time: 4 ms, Total time: 4 ms
mapdql> select * from test;
12.920000
8.410000
mapdql> select truncate(amount,1) from test;
12.900000
8.400000
mapdql> select truncate(amount,2) from test;
12.910001
8.400001
mapdql> select truncate(amount,3) from test;
12.919001
8.409000