59 lines
1.2 KiB
Plaintext
59 lines
1.2 KiB
Plaintext
The comparison of numeric values of different formats is inefficient. For instance, comparing a ``++COMP-3++`` with a ``++COMP-4++`` causes a performance drag because conversions are required under the covers before the comparison.
|
|
|
|
|
|
This rule raises an issue when variables with different ``++USAGE++`` clauses, or different numbers of decimal places are compared.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,cobol]
|
|
----
|
|
01 SUB1 PIC 9999 BINARY
|
|
01 WS-DISPLAY-1 PIC 9(12)
|
|
01 WS-PACKED-DEC PIC 9(12)V9(2) COMP-3
|
|
01 WS-BIN PIC S9999 COMP-4
|
|
01 WS-DISPLAY-2 PIC 9(4)
|
|
|
|
PERFORM VARYING SUB1 FROM WS-DISPLAY-1
|
|
BY WS-PACKED-DEC
|
|
UNTIL WS-BIN > WS-DISPLAY-2 *> Noncompliant
|
|
* ...
|
|
END-PERFORM
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,cobol]
|
|
----
|
|
01 SUB1 PIC 9999 BINARY
|
|
01 WS-DISPLAY-1 PIC 9(12)
|
|
01 WS-PACKED-DEC PIC 9(12)V9(2) COMP-4
|
|
01 WS-BIN PIC S9999 COMP-4
|
|
01 WS-DISPLAY-2 PIC 9(4)
|
|
|
|
PERFORM VARYING SUB1 FROM WS-DISPLAY-1
|
|
BY WS-PACKED-DEC
|
|
UNTIL WS-BIN > WS-DISPLAY-2
|
|
* ...
|
|
END-PERFORM
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
include::highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|