On 1-2-2018 16:30, Alex Peshkoff via Firebird-devel wrote:
Point taken, but my suggestion was more that we now don't utilize the
Decimal128 to its fullest for decimal, and users of the direct API now
need to handle decfloat and decimal(19+, x) in a very different manner
even though the underlying datatype is the same (and provides the
convenient feature to communicate the scale inline).
Damned, I still do not catch where is the problem. I reviewed ISQL code
- we have DecFixed interface that provides conversion to/from strings
and BCD. And it's implementation is less that once screen of a code.
Let me try to rephrase: for DECFLOAT we use Decimal128 which includes
the correct scale, and for DECIMAL(19+) we use Decimal128 with a scale
of zero, and the correct scale communicated externally, which then needs
to be applied separately.
That to me as a consumer of the API is an inconsistency (now having
implemented both for the wire protocol and legacy API), and it bugs me.
If Firebird would include scale in the Decimal128 in the DECIMAL case as
well, then after decoding the Decimal128 bytes, you are done: you have
the correctly scaled value, just like in the DECFLOAT case. In the
reverse direction you will need to correctly rescale/round the value(*),
but after that you only have to encode that to Decimal128 bytes.
Look, from the perspective of Jaybird, I have already implemented it as
it works now (pending some additional tests). However, this is an itch I
need to scratch, and after Firebird 4 is final, this is something we can
no longer change.
Mark
*) Although you could extend this behavior to accept any scale, and
leave rounding / overflow error handling to Firebird, but that might be
a bit too fancy (and 'magic').
--
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