java - Recover the original number from a float -
numbers being stored in database (out of control) floats/doubles etc.
when pull them out damaged - example 0.1
come out (when formatted) 0.100000001490116119384765625
.
is there reliable way recover these numbers?
i have tried new bigdecimal(((number) o).doublevalue())
, bigdecimal.valueof(((number) o).doublevalue())
these not work. still damaged result.
i aware make assumptions on number of decimal places , round them break numbers deliberately 0.33333333333 example.
is there simple method work rationals?
i suppose asking is there simple way of finding minimal rational number within small delta of float number?.
you can store numbers in database string , on retrieval parsedouble() them. way number wont damaged, same store there.
Comments
Post a Comment