correct computation of integer conversion, as per patch submitted by Peter Herweg -- see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23080