Rounding error in (**)/2

Today I wanted to do some testing with a more elaborate version,
still no negative numbers, but smallints also handled:

float_half_even(X,Y) :-
    M is msb(X),
    float_half_even(M, X, Y).

float_half_even(M, X,Y) :- 
     (M < 53;
      getbit(X, M-53) =:= 0; 
      getbit(X, M-52) =:= 0, M-53 =:= lsb(X)), !, Y is float(X).
float_half_even(_, X,Y) :-
     Y is nexttoward(float(X), 1E300).

I wanted redo some aggregate_all(count). But I banged my head
here. So a pure 100% Prolog testing got a little bit obstructed.

Not sure whether there is a Prolog predicate that maps to mpz_get_d?
Can I make a foreign predicate declaration or something?