ROUND function with optional argument

70 views
Skip to first unread message

Lukas Eder

unread,
Jun 13, 2011, 12:32:08 PM6/13/11
to H2 Database
The number of digits in the ROUND() function seems to be a mandatory
argument in H2:

http://www.h2database.com/html/functions.html#round

Many RDBMS (except SQL Server, Sybase, Ingres) make that an optional
argument and allow for calling ROUND(X) = ROUND(X, 0):

http://www.techonthenet.com/oracle/functions/round_nbr.php
http://dev.mysql.com/doc/refman/5.5/en/mathematical-functions.html#function_round
http://www.postgresql.org/docs/9.0/static/functions-math.html#FUNCTIONS-MATH-FUNC-TABLE

That might be a nice compatibility enhancement...

Cheers
Lukas

Thomas Mueller

unread,
Jun 16, 2011, 2:57:32 AM6/16/11
to h2-database
Hi,

This will be supported in the next release. Thanks!

Regards,
Thomas

Lukas Eder

unread,
Jun 18, 2011, 6:52:47 AM6/18/11
to H2 Database
> This will be supported in the next release. Thanks!

Thank you very much!

Vinod

unread,
Jun 29, 2012, 12:27:04 PM6/29/12
to h2-da...@googlegroups.com
I am facing a round function related issues:

SELECT ROUND(10.128) FROM DUAL
OutputExpected: 10, OutputActual: 10.0

I also tried SELECT ROUND(10.128, 0) FROM DUAL, but that also gives same result.

Even a multiplication which involves a double, but results into int value, gives a double output.
select 100 * 0.1 from dual
gives output as 10.0 instead of 10.

Is this the expected behavior ?

Vinod

unread,
Jun 29, 2012, 2:40:58 PM6/29/12
to h2-da...@googlegroups.com

Noel Grandin

unread,
Jun 29, 2012, 1:35:10 PM6/29/12
to h2-da...@googlegroups.com
yes, that's pretty much universal. There is no guarantee that the
result of a rounding operation will fit into an integer.
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/bJmEEXRnrvoJ.
>
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.
Reply all
Reply to author
Forward
0 new messages