Hi Zhan,
It's better, thanks, but still needs more work.
On 04/25/13 23:37, Zhan Jianyu wrote:
}
While we're at this, please put more attention into whitespace changes, esp. useless ones.
static HRESULT to_double(VARIANT *v, double *ret) { switch(V_VT(v)) { @@ -217,6 +221,27 @@ static HRESULT to_string(VARIANT *v, BSTR *ret) return S_OK; }
+static HRESULT banker_rounding(double dbval, int *result_val) +{
double frac_part;
double int_part;
*result_val = round(dbval);
This has two problems: - you don't handle values that are out of int range by assigning double value to int - round is not portable. As I mentioned you before, Wine needs to be C89 compatible. If we need some features that are not part of C89, we need to be careful about that and it often requires things like configure checks. In case of round, replacing it with floor(x+0.5) does the trick pretty well.
Cheers, Jacek
On 26 April 2013 10:27, Jacek Caban jacek@codeweavers.com wrote:
- round is not portable. As I mentioned you before, Wine needs to be C89
compatible. If we need some features that are not part of C89, we need to be careful about that and it often requires things like configure checks. In case of round, replacing it with floor(x+0.5) does the trick pretty well.
But that's going to do something different for negative values.
What you actually want to use is probably lrint(), although that's C99 as well, and affected by the current rounding mode. The latter may be what you want anyway, but would need tests.
On 04/26/13 12:02, Henri Verbeet wrote:
On 26 April 2013 10:27, Jacek Caban jacek@codeweavers.com wrote:
- round is not portable. As I mentioned you before, Wine needs to be C89
compatible. If we need some features that are not part of C89, we need to be careful about that and it often requires things like configure checks. In case of round, replacing it with floor(x+0.5) does the trick pretty well.
But that's going to do something different for negative values.
That will be different only for numbers with fractional part equal to 0.5, which we have to handle separately using both round and floor anyway.
Jacek
On 26 April 2013 12:41, Jacek Caban jacek@codeweavers.com wrote:
On 04/26/13 12:02, Henri Verbeet wrote:
On 26 April 2013 10:27, Jacek Caban jacek@codeweavers.com wrote:
- round is not portable. As I mentioned you before, Wine needs to be C89
compatible. If we need some features that are not part of C89, we need to be careful about that and it often requires things like configure checks. In case of round, replacing it with floor(x+0.5) does the trick pretty well.
But that's going to do something different for negative values.
That will be different only for numbers with fractional part equal to 0.5, which we have to handle separately using both round and floor anyway.
Yeah, it probably doesn't matter here, you just couldn't use it as a general replacement in libwine_port.