drem() (was: Re: [PATCH] KJS - fix toInt32 with some negativevalues (#61587))

Harri Porten harri at froglogic.com
Thu Jul 24 12:55:09 BST 2003


Hi,

Maks Orlovich wrote:
>
> Currently, KJS mis-calculates toInt32 values for some negative numbers. For
> example, -2478659068 is converted to 0x80000000, aka MIN_INT. This is because
> the remainder for dividing this by 2^32 is negative, so we don't readjust it
> (as it's certainly < 2^31) and below MIN_INT, so casting from floating point
> to integer in ValueImp::toInt32 clamps. The attached diff appears to be the
> proper fix to me. If this is OK,

Hmmm. You are right. Hadn't expected the result to become negative. How
about drem() ? I didn't knew about it before. It seems to does the job
nicely without the extra check. Is is portable ?

> is there anywhere where I can/should add a
> testcase for this?

I've added a test to khtmltests/js/operators.js

Harri.




More information about the kfm-devel mailing list