Search code examples
orientdb

In orient-db how can i round up a decimal value


In orientdb i have a sample query of my problem

select  eval('((23 + 46) *  1.0 ) / 2') as abc from SomeClass

above query returns 34.5 I want to round it up to 35. I applied asInteger() but it didn't work.

select  eval('((23 + 46) *  1.0 ) / 2').asInteger() as abc from SomeClass

above query returns 34 but i want it to be 35


Solution

  • I don't know if there are some native functions to achieve that.

    But you could create a javascript function with Studio called for example ceil

    and in the body do the work.

    try to insert this function.

    insert into OFunction set name = 'ceil', language = 'javascript', code = 'return Math.ceil(num);', parameters = ["num"]
    

    and then

    select  ceil(eval('((23 + 46) *  1.0 ) / 2'))