OLEAUT32: implement DECIMAL division, (generic) multiplication and
(generic) cast to string
Alex Villacis Lasso
a_villacis at palosanto.com
Mon Mar 28 14:04:19 CST 2005
While I prepared the patch for float->DECIMAL conversion (OLEAUT32:
VarDecFromR[4|8] must use same locale through conversion), I reviewed
the current status of the DECIMAL math operations. I was surprised (to
say the least) at how much functionality was missing:
- Cast to string is only implemented for zero-scaled DECIMAL numbers
smaller than 2^64 - 1; any other scale or value returns E_INVALIDARG.
- No check for NULL pointers as parameters to VarDecMul().
- VarDecMul() only multiplies by integers less than 2^32 -1 (as
indicated in a FIXME comment)
- VarDecDiv() is entirely unimplemented
- DECIMAL->Single|Double conversions use incorrect scaler for the high
32 bits of the DECIMAL number
- VarAdd() does not even attempt to handle DECIMAL values, even though
VarDecAdd() is fully implemented.
All of these issues are handled with the attached patch. I must note
that the algorithms for generic multiplication and division are based on
algorithms originally published in _Using_C_, by Lee & Mark Atkinson,
where they are used to implement multiplication and division for 128-bit
integers in a C++ example. These algorithms were then modified and
expanded to handle scaled numbers. In particular, DECIMAL division is
tricky because no remainder can be returned, so the integer remainder
has to be scaled and re-divided until it underflows, or exact division
is achieved. Maybe this is already well-known CS theory on
floating-point math, but it was an interesting exercise for me. Maybe
someone with a background on floating-point math can review the division
for me?
Conformance tests... Coming Soon!
Changelog:
* Implemented generic DECIMAL cast to string
* Implemented generic DECIMAL multiplication
* Implemented DECIMAL division
* Scaling corrected in DECIMAL cast to Single|Double
* VarAdd now handles DECIMAL parameters before trying integer operations.
Alex Villacís Lasso
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wine-oleaut32-decimal-implementation.patch
Type: text/x-patch
Size: 34623 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20050328/af6145d3/wine-oleaut32-decimal-implementation.bin
More information about the wine-patches
mailing list