Other OutSystems sites...
OutSystems Website
About Agility Blog
OutSystems Network
Login
Signup
Forums
Academy
Forge
Ideas
Forums
›
Technology & Integration
›
Arithmetic Division operator - behavior change
Arithmetic Division operator - behavior change
Acácio Porta Nova
Rank: #41
Posted on 2011-05-06
thumbs_up_ico
0
thumbs_down_ico
0
reply
post_link_ico
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
Statler & Waldorf
Rank: #11
Posted on 2011-05-09
thumbs_up_ico
1
thumbs_down_ico
0
reply
post_link_ico
awesome news. was a long time annoyance :D
Pedro Coelho
Rank: #87
Posted on 2011-05-09
thumbs_up_ico
0
thumbs_down_ico
0
reply
post_link_ico
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
Carlos Ribeiro da Fonseca
Rank: #79
Posted on 2011-05-09
thumbs_up_ico
0
thumbs_down_ico
0
reply
post_link_ico
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
Rank: #35
Posted on 2011-05-10
thumbs_up_ico
0
thumbs_down_ico
0
reply
post_link_ico
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
Quick Reply
Notify me by email when someone answers to my post
attachment
Choose File
No file chosen
Submit
Login to reply
Something on your mind?
Login to Start a Discussion
Top Forums Posters
Gonçalo Martins
Davide Marquês
Ricardo Silva
Richard Pearson
Statler & Waldorf
Charles Colaço
Fábio Silva
Justin James
Robert Chanphakeo
Kilian Hekhuis
See leaderboard
Online Training
On-demand video lessons to help you learn at your own pace.
Learn More