Use gdouble in x_to_wrap_x to avoid precision loss