On 24 October 2011 19:45, Joris Mooij <joris.mo...@gmail.com> wrote:
> Thanks for your answers so far.
>
> Actually, adding a constructor seems to be a simple two-line patch to
> mpixx.h:
> At line 1565 of the file mpirxx.h (in release 2.4.0), insert:
>   __gmp_expr(intmax_t l) { mpz_init_set_sx(mp, l); }
>   __gmp_expr(uintmax_t l) { mpz_init_set_ux(mp, l); }
>
> I realize that my question was not general enough. Although my code
> example only illustrated the incompatability of the constructor, the
> incompatibility also includes other ways in which a mpz_class can
> interact with 64-bit integers, for example, operator<=(long long) or
> operator+=(long long). So if you would only add the constructor, that
> would deal with one incompatibility, but many other related ones would
> remain. (At least that's what I believe - right now I am puzzled why
> the compiler cannot just automatically upcast the long longs to
> mpz_class and do the comparison or addition or whatever with those
> instead...)
>
> I've taken a look at the contents of mpixx.h, and it seems as if there
> is a lot of code duplication, implementing special cases for all
> possible integer types up to and including long ints. If one would
> duplicate all this code once more, for intmax_t, would that work?
> Because it looks like a lot of work, and I don't have Win64 myself
> around to test it, I would like to know first whether that would solve
> the problem, or whether there's a more fundamental underlying problem.
> For example, in all these __gmp_binary_{plus/minus/multiplies/*}
> structs, do the relevant corresponding mpz_* functions exist for
> intmax_t's? If these don't exist, then I would not know how to fix
> that without delving deeply into the internals of MPIR/GMP... so then
> I wouldn't even start to try fixing this.

To my knowledge there are not even mpz_add_ux, mpz_mul_ux functions,
etc. in the MPIR C library, let alone C++ analogues.

I think it is essentially assumed that a C/C++ program on Windows will
use unsigned longs and longs throughout, not 64 bit integers.

>
> From Brian's answer:
>
> On Oct 24, 7:14 pm, Cactus <rieman...@gmail.com> wrote:
>> The only functions that are capable of dealing with 64 bit integers are the
>> get_ux(), set_ux(), get_sx() and set_sx() functions that have been added to
>> handle 64-bit integers.
>
> I understand that only the constructor incompatibility can be solved
> easily, and that the other operations supplied by the C++ wrapper
> first need support in the C part of the library. Is that correct?
>

I think so.

Bill.

-- 
You received this message because you are subscribed to the Google Groups 
"mpir-devel" group.
To post to this group, send email to mpir-devel@googlegroups.com.
To unsubscribe from this group, send email to 
mpir-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/mpir-devel?hl=en.

Reply via email to