Don't modify the AmfInteger's value when calling toLength()