int compare(ComparisonMode mode, VarBufferPos buffer2, VarDefG varDef1, VarBufferPos buffer1) { // see http://h71000.www7.hp.com/DOC/73final/6297/6297_profile_010.html#group_items_sec // If the nonnumeric operand is a group item, the compiler treats the numeric operand as if it // had been moved into a group item the same size as the numeric operand and then compared. This // is equivalent to a group move. // The compiler ignores the description of the numeric item (except for length) and, therefore, // includes in its length any operational sign, whether carried as a separate character or as an // overpunched character. Overpunched characters are never ASCII numeric digits. They are // characters ranging from A to R, left brace ({), or right brace (}). Thus, the sign and the // digits, stored as ASCII bytes, take part in the comparison, and zeros are not supplied for P // characters in the PICTURE character-string. // String cs1 = varDef1.getRawStringExcludingHeader(buffer1); CStr cs1 = buffer1.getBodyCStr(varDef1); int n2 = getAsDecodedInt(buffer2); // String cs2 = getStringRightPadded(n2, ' ', varDef1.getTotalSize()); return StringAsciiEbcdicUtil.compare(mode, cs1, String.valueOf(n2)); }
int compare(ComparisonMode mode, VarBufferPos buffer2, VarDefX varDef1, VarBufferPos buffer1) { // see // http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGYLR205/6.1.6.5.3?SHELF=&DT=20000927030801&CASE= // see http://h71000.www7.hp.com/DOC/73final/6297/6297_profile_010.html#group_items_sec // If the nonnumeric operand is an elementary item or a literal, the compiler treats the numeric // operand as if it had been moved into an alphanumeric data item the same size as the numeric // operand and then compared. This causes any operational sign, whether carried as a separate // character or as an overpunched character, to be stripped from the numeric item so that it // appears to be an unsigned quantity. // In addition, if the PICTURE character-string of the numeric item contains trailing P // characters, indicating that there are assumed integer positions that are not actually // present, they are filled with zero digits. Thus, an item with a PICTURE character-string of // S9999PPP is moved to a temporary location where it is described as 9999999. If its value is // 432J (--4321), the value in the temporary location will be 4321000. The numeric digits take // part in the comparison. // String cs1 = varDef1.getRawStringExcludingHeader(buffer1); CStr cs1 = buffer1.getBodyCStr(varDef1); // int n2 = getUnsignedInt(buffer2); // String cs2 = getStringRightPadded(n2, ' ', varDef1.getTotalSize()); CStr cs2 = getAsAlphaNumString(buffer2); return internalCompare(mode, cs1, cs2); }
boolean isNumeric(VarBufferPos buffer) { CStr cs = buffer.getBodyCStr(this); return cs.isOnlyNumericComp0SignLeading(false); }