[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Re: drem() (was: Re: [PATCH] KJS - fix toInt32 with some
From:       Maks Orlovich <mo002j () mail ! rochester ! edu>
Date:       2003-07-24 12:46:04
[Download RAW message or body]

Harri Porten wrote:

> 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 ?
Hmm. Neat trick -- took me a bit to figure out why it works. I asked about
it on #kde-freebsd, though, and it doesn't seem like any recent FreeBSD
versions have it (at least the manpage isn't there since FreeBSD 2.0 era),
so I guess it goes as "no" under portable. Also, I guess toUInt32 might
need a similar fix? 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic