Fix sign bug in get_nearest.