lend = ((Int64Value)end).longValue();
} else {
// We need to be careful to handle cases such as plus/minus infinity and NaN
if (end.isNaN()) {
return "";
} else if (end.signum() <= 0) {
return "";
} else if (end.compareTo(slength) > 0) {
// this works even where the string contains surrogate pairs,
// because the Java length is always >= the XPath length
lend = slength+1;