You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
This looks to me like a discussion whether keep the type of the variable the same or to change the type from double (floating point rep) to integer. To make that kind of decision we really ought to know the purpose of the variable and how it is going to be used and any other considerations like speed and memory.
Fortunately it is easily testable. Run the attached script, investigate the math. Works for me. MQL seems to deftly manage distinguishing between true integers and "equivalent" integers as you put it and mathfloor, mathceil, and mathround all perform as expected.
That condition is already covered in the referenced script.
Not tried, but reading this brought up the question in my mind of trying
Otherwise your assuming that the Print function does not do its own type casting to integer.
Not tried, but reading this brought up the question in my mind of trying
Otherwise your assuming that the Print function does not do its own type casting to integer.
I'm not making that assumption, I use the boolean logic in the script to ensure the result is truly an integer, but the comments that have been made above are expanding on that.
One option I have not seen in converting to and integer is
of course floating point arithmatic has errors and then there is the question of if you want to round up or round down.