On 8-12-2015 11:37, Adriano dos Santos Fernandes wrote:
> On 08/12/2015 08:29, Mark Rotteveel wrote:
>> I'd prefer if anything is changed, this is not done without resorting
>> hackish solutions that will just create another set of confusion, but
>> instead by using generally accepted arbitrary precision decimal
>> calculation rules from standards like ANSI X3.274-1996 or IEEE 754R, or
>> alternatively by looking at what Java's BigDecimal does, or maybe what
>> other database engines do (although there it seems as confusing as with
>> Firebird).
>>
>>
> We're already using libtommath in our sources, so I suppose the math per
> see is not the problem for our implementation.

I haven't read those standards myself (I have better things to do ;), 
but I believe they also specify something about the scale to apply to 
the final result.

I know that Java uses scale for division is the opposite of what 
Firebird does. See 
http://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html :

Operation  Preferred Scale of Result
Add        max(addend.scale(), augend.scale())
Subtract   max(minuend.scale(), subtrahend.scale())
Multiply   multiplier.scale() + multiplicand.scale()
Divide     dividend.scale() - divisor.scale()

The first three match with the SQL standard and what Firebird does.

On the other hand, a lot of the "problems" would already be solved by 
removing or at least increasing the existing max precision of 18 (eg for 
postgresql the max precision it allows you to specify is 1000; it 
supports a larger precision).

Mark
-- 
Mark Rotteveel

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to