rspec/rules/S2184/description.adoc
Arseniy Zaostrovnykh 7ca29f686f Force linebreaks
2021-02-02 15:02:10 +01:00

8 lines
738 B
Plaintext

When arithmetic is performed on integers, the result will always be an integer. You can assign that result to a ``++long++``, ``++double++``, or ``++float++`` with automatic type conversion, but having started as an ``++int++`` or ``++long++``, the result will likely not be what you expect.
For instance, if the result of ``++int++`` division is assigned to a floating-point variable, precision will have been lost before the assignment. Likewise, if the result of multiplication is assigned to a ``++long++``, it may have already overflowed before the assignment.
In either case, the result will not be what was expected. Instead, at least one operand should be cast or promoted to the final type before the operation takes place.