I'm new here, coming from MT4. I have a problem and I don't know what is wrong. I want to divide the result of two functions stored in float variables, but the print is giving me zero. I found the error source to be the following, if I type "double a = 2/4; Print(a);" in the OnInit() or the OnTick() functions and I run it, the console returns me "0.0". It happens in all the cases where the result should be <1.
On more examples, 4/2 returns 2, 6/2 returns 3, but 5/2 also returns 2, so I think it is basically killing the decimal part. If I try with double variables, it behaves the same.
Have you any idea on why is this happening and how can I get over it?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi guys,
I'm new here, coming from MT4. I have a problem and I don't know what is wrong. I want to divide the result of two functions stored in float variables, but the print is giving me zero. I found the error source to be the following, if I type "double a = 2/4; Print(a);" in the OnInit() or the OnTick() functions and I run it, the console returns me "0.0". It happens in all the cases where the result should be <1.
On more examples, 4/2 returns 2, 6/2 returns 3, but 5/2 also returns 2, so I think it is basically killing the decimal part. If I try with double variables, it behaves the same.
Have you any idea on why is this happening and how can I get over it?
Thanks a lot in advance.