I have an attribute of type :db.type/float
in my Datomic Cloud (solo) instance. When I query for that value, however, I get values of type java.lang.Double
. (I actually have 6 float attributes and they all behave this way.)
Is this a bug? I can't see anything in the documentation that describes this behavior. In fact, the schema reference seems to specifically say that it should be float value and not a double.
This is not a big problem, but it is an annoyance because the values I'm transacting as floats are getting extra (noisy) precision added to them, so that e.g. when the user enters a 3.7, it actually shows up as 3.700000047683716. This isn't difficult to fix by casting to float, but it was surprising.
I only see this behavior in Datomic Cloud, by the way. Using dev-local correctly shows the value as a float.
Here's some relevant exchanges from a REPL session demonstrating the issue:
user> (d/q '[:find ?attr-type ?value :where
[71587003061240196 :student/gpa-weighted-9 ?value]
[:student/gpa-weighted-9 :db/valueType ?t]
[?t :db/ident ?attr-type]]
(d/db conn))
[[:db.type/float 3.700000047683716]]
user> (type (-> *1 first second))
java.lang.Double
user> (float 3.700000047683716)
3.7