[mercury-users] Fun with signed integers.

Peter Wang wangp at students.csse.unimelb.edu.au
Sun Feb 25 12:37:45 AEDT 2007


On 2007-02-24, Julian Fondren <ayrnieu at gmail.com> wrote:
> 
> The first comes from a Mercury program, using my work-in-progress random.m
> replacement.  The second uses the canonical tt800.c .  Both have the same
> seed.

You need an unsigned right shift where the original C code uses '>>', e.g.

    :- func int `urs` int = int.
    :- pragma foreign_proc("C",
	(A::in) `urs` (B::in) = (C::out),
	[will_not_call_mercury, promise_pure, thread_safe],
    "
	C = (MR_Unsigned) A >> B;
    ").

Peter

--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list