db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: round in derby
Date Thu, 26 Jan 2006 17:16:07 GMT
firass wrote:

> hi.
> 
> plz can you tell me where i can ask questions , and if i am in the
> correct place plz answer me
> my question: is there a build in function in derby that do round for the
> values in the sql sentance?
> and if not can i make a function and how to do it?

Some new maths functions have been added in 10.2. They are listed in
DERBY-475

http://issues.apache.org/jira/browse/DERBY-475

CEIL or CEILING correspond to java.lang.Math.ceil
FLOOR corresponds to java.lang.Math.floor

They operate only on DOUBLE values, hence are imprecise.

Not sure if they will help you.

ij> create table t (d double);
0 rows inserted/updated/deleted
ij> insert into t values 1.3, -0.5, 0.5, 34.9, -35.7;
5 rows inserted/updated/deleted
ij> select d, floor(d) as floor, ceiling(d) as ceiling from t;
D                     |FLOOR                 |CEILING
--------------------------------------------------------------------
1.3                   |1.0                   |2.0
-0.5                  |-1.0                  |0.0
0.5                   |0.0                   |1.0
34.9                  |34.0                  |35.0
-35.7                 |-36.0                 |-35.0


Dan.


Mime
View raw message