octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: integer arithmetics


From: Jaroslav Hajek
Subject: Re: integer arithmetics
Date: Thu, 2 Oct 2008 10:46:08 +0200

On Thu, Oct 2, 2008 at 9:30 AM, Jaroslav Hajek <address@hidden> wrote:
> On Thu, Oct 2, 2008 at 7:47 AM, Jaroslav Hajek <address@hidden> wrote:
>> On Wed, Oct 1, 2008 at 10:36 PM, John W. Eaton <address@hidden> wrote:
>
>>
>> I'll resend an update.
>>
>
>
> And here it is.
>

Sorry, here it is. It appears to work reasonably well even if I
undefine HAVE_FAST_INT_OPS and SIZEOF_LONG_DOUBLE. I fixed a few
places and modified multiplication and division to get correct
behavior in the common cases like 2*a or a/3.
If you want the illustration of the remaining problems, try:
((int64(2**62) + 2) * 0.5) - (int64(2**61) + 1)
which should, in theory, give zero. These are really corner cases, as
nobody would probably do a*0.5 and intend integer arithmetics, but
still an inconsistency. I think we may warn about it in the manual. If
you replace * 0.5 with / 2, it should work (though it's still division
by a double).

Nothing like this should happen for addition and subtraction - try
(3*2**62 + (1+intmin('int64'))) == (int64(2**62)+1)
or
(3*2**63 - intmax('uint64')) == (uint64(2**63)+1)

These should both be true (note that in both cases the first operand
is outside the integer range).

OK to push?
I'll contribute some tests later.

regards

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

Attachment: int_patch2.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]