Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
AcacioPN
Staff
16
Views
4
Comments
Arithmetic Division operator - behavior change
Question
Hello everyone
This post is to inform the OutSystems community that the behavior of the arithmetic Division operator (
/
) has been changed.
The change is related to the division of Integer numbers. As it was before, in some cases dividing two integer values would generate an Integer result, and integer division was executed; in other cases, decimal division of the two integer values was executed, and the result was a decimal value.
For example, depending on the exact context, you could have:
10 / 4 = 2 (and the result would be an Integer expression);
10 / 4 = 2.5 (and the result would be a Decimal expression);
To fix this inconsistency, OutSystems has changed the behavior to be the same in all cases: decimal division is executed, and the result is a Decimal expression, in all cases. This change is effective in the following Agile Platform versions:
Agile Platform 4.2 - starting with revision
4.2.4.79
Agile Platform 5.0 - starting with revision
5.0.2.29
Agile Platform 5.1 - starting with revision
5.1.1.18
This change does not affect calculations where dividing values were being explicitly converted to Decimal, or the result explicitly converted to Integer:
IntegerToDecimal(10) / IntegerToDecimal(4) = 2.5 (this did not change);
DecimalToInteger(10/4) = 2 (this did not change as well).
If you have any questions regarding this subject, please send an email to OutSystems Product Support (
support@outsystems.com
).
Regards,
Acácio Porta Nova
OutSystems Product Support
J.
MVP
awesome news. was a long time annoyance :D
Pedro Coelho
MVP
This should be marked as a breaking change, since ppl (at least I did) used the division operator having in consideration exactly what was removed (int division if both parameters were ints, decimal division if at least one of them was decimal)
We have to go back to all the projects and go one by one to see which should be kept as integer division (and make the appropriated changes) and the ones who don't need any change, to ensure the expected results are still obtained
Carla Ribeiro da Fonseca
What Pedro said.
Since the previous behaviour is the expected behaviour in C# , C++, Java and Python (and probably every other strong-typed languages) a bigger warning of this change is probably a good idea.
João Rosado
Staff
Hi,
Its actually not that big of a change, since most of the results were already decimal results. These changes only made all results coerent.
The only 2 very specific situations where it actually would give integer division was
Decimal
To
Integer
(10) /
DecimalTo
Integer(4)
or
IntegerVariableA / IntegerVariableB
This is what Acacio means by "
depending on the exact context".
All others situations always returned decimals. So its very unlikelly that this change will have a big impact on running applications.
For example, this was already a decimal result
IntegerVariableA / (IntegerVariableA * 2) = 0.5
as well as writting directly on an expression
1/2 = 0.5
Regards,
João Rosado
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
Loading...