octave-maintainers
[Top][All Lists]
Advanced

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

Re: 3.0.1 release?


From: Michael Goffioul
Subject: Re: 3.0.1 release?
Date: Tue, 8 Apr 2008 16:58:29 +0200

On Tue, Apr 8, 2008 at 4:41 PM, David Bateman
<address@hidden> wrote:
>  Then I'm not sure I understand, it is clear that the example
>
>
>   Bmax = bitmax;
>   A = bitshift(Bmax,-2);
>   bitxor(cast(A,'uint64'),cast(Bmax,'uint64'))
>
>
>  Is incorrect in the windows version (I used your 3.0 MSVC binary) of
>  Octave, and that corresponds to the piece of code I sent.. Can you
>  confirm that this is incorrect under MSVC (that is it doesn't return
>  6755399441055744). I checked the casts above independently and they are
>  returning the correct answers, so the issue is in the bitxor function in
>  src/bitfcns.cc. This calls the code fragment
>
>           uint64NDArray x (args(0).array_value ()); \
>           uint64NDArray y (args(1).array_value ());    \
>           if (! error_state) \
>         BITOPX (OP, FNAME, uint64NDArray); \
>           retval = retval.array_value (); \
>
>  in the BITOP macro, and BITOPX call a fragment
>
>         for (int i = 0; i < nelx; i++) \
>           if (is_scalar_op) \
>         for (int k = 0; k < nely; k++) \
>           result(i+k) = x(i) OP y(k); \
>
>  where "OP" is "^". This then calls the operator ^ from
>  liboctave/oct-inttypes.h
>
>  #define OCTAVE_INT_BITCMP_OP(OP) \
>   template <class T> \
>   octave_int<T> \
>   operator OP (const octave_int<T>& x, const octave_int<T>& y) \
>   { \
>     return x.value () OP y.value (); \
>   }
>
>  OCTAVE_INT_BITCMP_OP (^)
>
>  where T is of type uint64_t and x.value() returns a value of type
>  uint64_t. I don't see where this can go wrong and so laid the cause on
>  the ^ operator for uint64_t types in MSVC. Frankly I'm stumped why this
>  is wrong under MSVC..

I'll check further this evening or tomorrow. In the meantime, I did this
simple check: using the code you sent me, I derived the following:

int main (void)
{
        uint64_t a = 0x001FFFFFFFFFFFFFUL^0x0007FFFFFFFFFFFFUL;
        std::cerr << 0x001FFFFFFFFFFFFFUL << std::endl;
        std::cerr << 0x0007FFFFFFFFFFFFUL << std::endl;
        std::cerr << a  << std::endl;
        return 0;
}

When executed, it gives:

9007199254740991
2251799813685247
6755399441055744

Then I executed the following in octave:

Bmax = bitmax;
A = bitshift(Bmax,-2);
cast(Bmax,'uint64'), cast(A,'uint64'),
bitxor(cast(A,'uint64'),cast(Bmax,'uint64'))

which returned

ans = 9007199254740992
ans = 2251799813685247
ans = 11258999068426239

Notice the 1-bit difference in the first entry. If I'm right, they
should be equivalent,
right?

Michael.


reply via email to

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