[m-rev.] for review: implement float library for Java
Ralph Becket
rafe at cs.mu.OZ.AU
Thu Dec 11 15:21:24 AEDT 2003
James Goddard, Thursday, 11 December 2003:
>
> + % In hashing a float in .NET or Java, we ensure that the value is
> + % non-negative, as this condition is not guaranteed by either API.
> +
> :- pragma foreign_proc("C",
> float__hash(F::in) = (H::out),
> [will_not_call_mercury, promise_pure, thread_safe],
> @@ -430,7 +495,23 @@
> float__hash(F::in) = (H::out),
> [will_not_call_mercury, promise_pure, thread_safe],
> "
> - H = F.GetHashCode();
> + int Code = F.GetHashCode();
> + if( Code < 0 ) {
> + H = Code ^ 1;
> + } else {
> + H = Code;
> + }
> +").
> +:- pragma foreign_proc("Java",
> + float__hash(F::in) = (H::out),
> + [will_not_call_mercury, promise_pure, thread_safe],
> +"
> + int Code = (new java.lang.Double(F)).hashCode();
> + if( Code < 0 ) {
> + H = Code ^ 1;
> + } else {
> + H = Code;
> + }
> ").
You need `H = -Code ^ 1' or somesuch in order to change the sign for the
negative Code cases.
Otherwise that looks great.
-- Ralph
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list