« Return to Thread: Floating point imprecision in activerecord-jdbc-adapter?

Re: Floating point imprecision in activerecord-jdbc-adapter?

by Michael Campbell-4 :: Rate this Message:

Reply to Author | View in Thread

Uwe Kubosch wrote:

> When using Float/Double, you should always be prepared for small
> variations during handling.
>
> If you want to store and retrieve a decimal number without it being
> subject to rounding etc, you should use the DECIMAL column type.  It
> will be converted to a BigDecimal when loaded by ActiveRecord, and it
> will not suffer any rounding/conversion changes.

+1.  That MRI and JRuby do different things seems interesting, but beyond that
this is pretty standard post-COBOL-BCD numeric computing fare.

For the OP, I think most unit test frameworks provide some sort of
assertEquals(floatingpoint_value_1, floatingpoint_value_2, allowed_variance)
type of call.  If not, it's trivial to write.



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Floating point imprecision in activerecord-jdbc-adapter?