Closed vizcay closed 9 years ago
fb originated before BigDecimal was available. Using double was non-ideal, but usable in a majority of cases and did not incur extra dependencies. A patch that improves the status quo without breaking backward compatibility or significantly impacting performance would be welcomed.
fb-only scenarios as well as ActiveRecord must be considered.
Rowland: Hi, after your last fix about the rounding issue I've looked at little closer at the fb implementation because something got my attention (extracted from fb.c@2039)
FB is handling fixed precision decimals (sqlscale > 0) converting them back to C doubles and ruby floats..! But wait, I said.. at ActiveRecord I'm pretty sure I'm getting back BigDecimals.. that's true, but they are being instantiated from the Floats so the precision lost already happened!
I 've made this simple script to expose the issue:
That output's
So actually this is what is happening here:
So the question is.. do you think is possible to, instead of instantiate a Float, to return a BigDecimal there without creating havoc on the user base? I may even try to pull the patch myself..
Something like: