rspec/rules/S1619/rpg/rule.adoc

50 lines
898 B
Plaintext
Raw Normal View History

== Why is this an issue?
When storing numeric fields, using an odd number of digits allows the sign to be included in the storage area without wasting any space.
For example the number -1234567, when packed as 7 digits is stored as follows.
----
1357
246-
----
thus taking up only 4 data slots. but when packed as 8 characters it uses 5 data slots
----
02467
0135-
----
or when 7 digits, non-packed, it will be stored as 8 data slots, including the sign.
----
FFFFFFF6
12345670
----
=== Noncompliant code example
[source,rpg]
----
D NUMFLD S 8P 0
D NUMFLD S 7S 0
----
=== Compliant solution
[source,rpg]
----
D NUMFLD S 7P 0
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
endif::env-github,rspecator-view[]