DECIMAL data type is rounding values?

51 views
Skip to first unread message

peter.fu...@gmail.com

unread,
May 6, 2018, 7:40:17 PM5/6/18
to OrientDB
Hi everyone. I'm quite new to OrientDB, but have found it because it appeared it has support for large numbers.

The DECIMAL data type appeared to be the solution.
https://orientdb.com/docs/last/Types.html says its without rounding and any number.

However, when I try to create a vertex from the studio with a DECIMAL value of 9223372036854775807, it gets saved as 9223372036854780000.
Is this expected behavior?
Do I need to user another data type?

It happens in version 2.2.34 and 3.0.0RC2

Cheers,
Peter

Luigi Dell'Aquila

unread,
May 7, 2018, 5:18:52 AM5/7/18
to orient-...@googlegroups.com
Hi Peter,

How are you instantiating the value? From SQL? Did you try to use decimal() function?

Thanks

Luigi

--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

peter.fu...@gmail.com

unread,
May 7, 2018, 6:09:43 AM5/7/18
to OrientDB
Hi Luigi,
Thank you for replying so quickly.

I've tried it from the studio through the tab Schema -> Vertex Classes -> New Record dialog.

It also happens if I do the following from the Studio SQL console:
INSERT INTO bigvertex (bigvalue)
          VALUES (DECIMAL("9223372036854775807"))

I would like to use OrientDB to store edges with an attribute describing amounts - big numbers up to 80 digits, and be able to do calculations like SUM or AVG on them.
I was hoping OrientDB is the right tool, maybe I'm just doing something wrong?

Cheers,
Peter

Luigi Dell'Aquila

unread,
May 7, 2018, 6:46:00 AM5/7/18
to orient-...@googlegroups.com
Hi Peter,

I just did a quick test, the problem is only on the REST/JSON layer.
If you do the queries from console (or from a binary driver) you'll see that the results are correct and the numbers are not rounded.
Could you please open an issue here https://github.com/orientechnologies/orientdb/issues
I'll try to fix it asap

Thanks

Luigi


--

Luigi Dell'Aquila

unread,
May 7, 2018, 6:48:53 AM5/7/18
to orient-...@googlegroups.com
Mmm... just thinking out loud... JSON does not allow absolute precision numbers, so there is no native way to pass the equivalent of a BigDecimal.
The alternatives are:
- keep sending a number and lose precision
- pass the value as a string, but it will make it harder to manipulate it on the client and won't help when you convert it to a number in js. Moreover, it will break backward compatibility in OrientDB, so I don't know if I can do it...

Thanks

Luigi

Reply all
Reply to author
Forward
0 new messages