Integer division (cast?)

0
Microflow expressions have a mod operator not an integer division. No problem, I can mod first then divide: ($VanTot/VanMaand-$VanMo) : 12 However! These are all integers, but Mendix makes the division outcome a float. 1) How do I now make my microflow (Create integer variable) return an integer? I couldn't find a 'cast' function. All I have is an error message ;-) 2) Will Mendix guarantee me that I will not have rounding errors (and hence, incorrect results)?
asked
1 answers
0

This is simply because 4 : 3 is not an integer but a float, so we cant guarantee that your division does not return a float.

1) just use round(($VanTot/VanMaand-$VanMo) : 12)

2) No, that is impossible in a system that works with discrete numbers composed in bits and bytes, since float numbers are an estimation and not an exact number (imagine how many bytes you would need to store the value of 1/3 exactly).

However, in almost any case you encounter in 'normal' applications the answer will be correct.

answered