MQL4 won't divide in print out

 

Hi, I'm running into strange issues with division and MQL4 (not the first time, but this time it's worse).

In the past I"ve had to work around some division hiccups that MQL4 didn't want to do, in some of the more compound structured formulas.

But this time, it won't divide at all, at least in printout. Here is the print out and code for visual examples.

Any ideas what I may not be doing that I could be doing?

Print("1/301968=    " ,DoubleToStr(1/301968,8),"  1/30196=  ",DoubleToStr(1/30196,8),"     ",DoubleToStr((1/301968),8),"  1/2=  ",1/2,"   3/1  ",DoubleToStr((301968/1),8),"  ",ma200);

Print("1/300=    " ,DoubleToStr(1/300,8));

if(1/301968 <1)Print(DoubleToStr(1/301968,8),"  Calculated division if statment   ");


if(1/2==0.5)Print(DoubleToStr(1/2,8),"  Calculated division if statment   ");<This code did not print out at all
 
moneycode:

Hi, I'm running into strange issues with division and MQL4 (not the first time, but this time it's worse).

In the past I"ve had to work around some division hiccups that MQL4 didn't want to do, in some of the more compound structured formulas.

But this time, it won't divide at all, at least in printout. Here is the print out and code for visual examples.

Any ideas what I may not be doing that I could be doing?

Don't use an int 1 use a double 1.0 see typecasting
 
RaptorUK:
Don't use an int 1 use a double 1.0 see typecasting


Thanks

I was first under the impression it was dividing, but just not printing (due to the first if statement causing it to print, but just not showing the quotient in printout)

My original problem was using variable that was type double, but in the equation I also added a 1.

My second if statement that didn't call the print function clued me in that it wasn't dividing correctly after all, even though it was dividing.

I did some more tests and figured out what you said, then tried to rush back over here and change my post before I looked stupid... too late. thanks, alot..

Sometimes wasting 3 hours on a stupid problem is what it takes to burn it into the "old" memory.

 
RaptorUK:
Don't use an int 1 use a double 1.0 see typecasting

Actually throughout my code I was using counters such as var++, and they were type int.

Not realizing that later in the code I used them sometimes in formulas. So this actually brought out an important weakness in my code.

I've now changed my counters to type double.

When using counters to select array elements though, they must be int type. So I'm transferring their values to similar named double variables prior to calculations.

This was actually a very important catch, that could have laced my codes with future problems. .

 
moneycode:


Sometimes wasting 3 hours on a stupid problem is what it takes to burn it into the "old" memory.

Exactly
 
moneycode: Sometimes wasting 3 hours on a stupid problem is what it takes to burn it into the "old" memory.

You were allot more modest about it. When I did 1/2 and got 0 instead of 0.5 I was ready to jump on the forum and condemn meta-quotes for not finding such an obvious bug.

It didn't take me too long to realize that 99% of the time, when someone yells bug, the person yelling bug doesn't have a clue how things are implemented.

Starting from the premise that its my fault (instead of meta-quotes) is the biggest troubleshooting trick I've ever learned. After 3 hours trying and searching, I usually understand why.

That beats running into this place screaming bloody murder and end-up looking dumb .

 
ubzen:


That beats running into this place screaming bloody murder and end-up looking dumb .

I composed a thread about "Remainder from zero divide." yesterday . . . never seen it before . . . then I did a little more reading, wrote a tiny bit of test code and then understood the cause, then deleted my thread I hadn't yet sent
Reason: