if (start instanceof IntegerValue) {
lstart = ((IntegerValue)start).longValue();
} else {
NumericValue rstart = start.round();
// We need to be careful to handle cases such as plus/minus infinity
if (rstart.compareTo(IntegerValue.ZERO) <= 0) {
return s;
} else if (rstart.compareTo(new IntegerValue(slength)) > 0) {
// this works even where the string contains surrogate pairs,
// because the Java length is always >= the XPath length
return "";