On 21-1-2018 21:48, Mark Rotteveel wrote:
I think there are still a number of issues or deficiencies with the DECFLOAT implementation that I think need to be addressed and fixed.

I'm not sure of the best way to address these. Please let me know how to move forward with these points (create/update tickets in Jira, further discussion, etc)?

Below is an inventory of the problems I think need addressing; I might come up with others later.

[..]


2. Underflow should yield zero, not an error

Currently, underflow conditions raise an error, instead it should round to zero.

The SQL:2016 specification in 5.3 <literal> and 6.13 <cast specification> explicitly mention that underflow with literals or casts should yield zero, not an exception, so for example a literal 1.0E-7000 or cast('1.0E-7000' as decfloat(34)) (which is too small to be represented) should not raise an errors, but instead yield 0.

The wording in section 6.29 <numeric value expression> at first glance would seem to suggest that we would need to raise an exception if the result of an expression is an underflow, but I don't think that is how it is intended and instead we should yield zero as well. Similar to what happens with calculations involving real and double precision.

This would be allowed because of the phrasing "If the most specific type MST of the result of an arithmetic operation is the decimal floating point type, then the result is an implementation-defined value IV of MST such that no other value of MST is strictly between IV and the mathematical result MR of the operation."

In the case of calculations that yield such a small value, there is no other value than 0 that is "strictly between IV and the mathematical result MR of the operation". This would also nicely fit with the behaviour described for literals and cast

Tickets:
CORE-5700 - DECFLOAT underflow should yield zero instead of an error

The definition in 4.4.2 Characteristics of numbers is probably clearer support for the fact this also applies to the result of calculations:

"""
An approximation obtained by truncation or rounding of a numeric value N for an approximate numeric type T or the decimal floating-point type T is a value V in T such that there is no numeric value in T distinct from that of V that lies between the numeric value of V and N, inclusive.

If there is more than one such value V then it is implementation-defined which one is taken. It is implementation-defined which numeric values have approximations obtained by rounding or truncation for a given approximate numeric type or a given decimal floating-point type.

Whenever a numeric value is assigned to an approximate numeric value site or a decimal floating-point value site, an approximation of its value is represented in the declared type of the target. The value is converted to have the precision of the target.
"""

Mark
--
Mark Rotteveel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to