but when i do 1000000000 * 3.0 = 3000000000
But this is didnt happend when i multiply with 1 or 2. Can some one explain?
In the first example, it is doing integer multiplication but the result is greater the limit of an "int" datatype (which is 2 147 483 647), and so the result is "overflowing" or "wrapping" and gives you a negative number. To fix this, typecast it as a "long" (which has a limit of 9 223 372 036 854 775 807).
In the second example, it is doing floating-point multiplication and the results are within the capabilities of that datatype.
In the first example, it is doing integer multiplication but the result is greater the limit of an "int" datatype (which is 2 147 483 647), and so the result is "overflowing" or "wrapping" and gives you a negative number. To fix this, typecast it as a "long" (which has a limit of 9 223 372 036 854 775 807).
In the second example, it is doing floating-point multiplication and the results are within the capabilities of that datatype.
Thanks for your reply bro. SO i have to use Long rather than int
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi i got case when code on mql4
but when i do
1000000000 * 3.0 = 3000000000
But this is didnt happend when i multiply with 1 or 2
Can some one explain?