KJS::SimpleNumber on 64 bit machines

Maciej Stachowiak mjs at apple.com
Wed Oct 1 16:19:59 CEST 2003


On Oct 1, 2003, at 2:57 PM, Harri Porten wrote:

> On Wed, 1 Oct 2003, Maciej Stachowiak wrote:
>
>> I think this patch will fix it, but I don't have a 64-bit platform to
>> test on. Could you try it? It shuts up the warnings and also uses all
>> 64 bits (which is not really required but seems nice).
>
> I added to L's to the 1 constants to avoid two warnings about the shift
> exceeding the types range.

OK, good catch.

> I noticed that our fits(double) code is different to yours (the patch
> didn't apply cleanly). Peter, could you comment on the
> IS_NEGATIVE_ZERO() check ? Something that Apple should be using, too ?

Yeah, that sounds like a good fix. It seems like as-is, SimpleNumber 
would lose the -0 +0 distinction. I'll pick it up from your tree.

> I've also applied other patches to avoid running into NaN in the code
> path. You might want to use them two to let our code base not drift
> further apart.

OK, I'll test and land these if they work OK. Thanks!

>
> This one really makes sense (there is no need for a signed NaN):
>
> --- ustring.cpp 11 Jun 2003 17:28:01 -0000      1.59
> +++ ustring.cpp 1 Oct 2003 21:54:28 -0000       1.60
> @@ -650,8 +650,8 @@ double UString::toDouble( bool tolerant
>    while (isspace(*c))
>      c++;
>    // don't allow anything after - unless tolerant=true
> -  if ( !tolerant && *c != '\0')
> -    d = NaN;
> +  if (!tolerant && *c != '\0')
> +    return NaN;
>
>    return d*sign;
>  }
>
> These three are according to the spec's calculation and also nuke a
> TODO. If the additional function calls are an issue we could ifdef 
> those
> with __alpha.
>
> diff -u -3 -p -r1.165 -r1.167
> --- internal.cpp        27 Sep 2003 19:24:28 -0000      1.165
> +++ internal.cpp        1 Oct 2003 21:18:37 -0000       1.167
> @@ -992,7 +992,9 @@ double KJS::roundValue(ExecState *exec,
>    if (v.type() == UndefinedType) /* TODO: see below */
>      return 0.0;
>    double n = v.toNumber(exec);
> -  if (n == 0.0)   /* TODO: -0, NaN, Inf */
> +  if (isNaN(n))
> +    return NaN;
> +  if (n == 0.0)   /* TODO: -0, Inf */
>      return 0.0;
>    double d = floor(fabs(n));
>    if (n < 0)
> --- value.cpp   1 Oct 2003 20:53:01 -0000       1.31
> +++ value.cpp   1 Oct 2003 21:10:07 -0000
> @@ -109,6 +109,8 @@ int ValueImp::toInt32(ExecState *exec) c
>      return (int)i;
>
>    double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
> +  if (isNaN(d) || isInf(d) || d == 0.0)
> +    return 0;
>    double d32 = fmod(d, D32);
>
>    //Make sure we use the positive remainder. This matters since this 
> may
> be
> @@ -129,6 +131,8 @@ unsigned int ValueImp::toUInt32(ExecStat
>      return i;
>
>    double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
> +  if (isNaN(d) || isInf(d) || d == 0.0)
> +    return 0;
>    double d32 = fmod(d, D32);
>
>    return static_cast<unsigned int>(d32);
>
>
>
> Harri.
>
>
> _______________________________________________
> Khtml-devel at mail.kde.org
> http://mail.kde.org/mailman/listinfo/khtml-devel



More information about the Khtml-devel mailing list