| / | Forum |
|
fbj
2008.10.30 16:04
cmon support, how bout some SUPPORT ??? . PLEASE notice how MY HACK works correctly and MathMod() still results in wrong answers. . OR does this highlight a bug in the interpreter/compiler/watevr u using...? why? is the if condition that is giving issue ?? . i have demonstrate below and also on another thread how about some answers??? i not mind i mistaken - but cmon, GIVE SOME SUPPORT, ok? if i all wrong ok, put me right but let's get this sorted thankyou . #property show_inputs extern double dVolume=0.1; int start() { double dLotStep=0.01; Print("<1> MathMod(",DoubleToStr(dVolume,8),",",DoubleToStr(MarketInfo(Symbol(),MODE_LOTSTEP),8),")=",MathMod(dVolume,MarketInfo(Symbol(),MODE_LOTSTEP))); if(MathMod(dVolume,MarketInfo(Symbol(),MODE_LOTSTEP))!=0) Print("<1> dVolume incorrect"); else Print("<1> dVolume correct"); Print("<2> MathMod(",DoubleToStr(dVolume,8),",",DoubleToStr(dLotStep,8),")=",MathMod(dVolume,dLotStep)); if(MathMod(dVolume,dLotStep)!=0) { Print("<2> dVolume incorrect"); } else Print("<2> dVolume correct"); Print("<3> dVolume - dLotStep * MathFloor(dVolume/dLotStep) = " ,DoubleToStr(dVolume,8)," - ",DoubleToStr(dLotStep,8)," * MathFloor(",DoubleToStr(dVolume,8),"/",DoubleToStr(dLotStep,8) ,") = ",dVolume - dLotStep * MathFloor(dVolume/dLotStep)); if(dVolume - dLotStep * MathFloor(dVolume/dLotStep)!=0) { Print("<3> dVolume incorrect"); } else Print("<3> dVolume correct"); return(0); } /* <3> dVolume correct <3> dVolume - dLotStep * MathFloor(dVolume/dLotStep) = 0.05000000 - 0.01000000 * MathFloor(0.05000000/0.01000000) = 0 <2> dVolume incorrect <2> MathMod(0.05000000,0.01000000)=0 <1> dVolume incorrect <1> MathMod(0.05000000,0.01000000)=0 inputs: dVolume=0.05; <3> dVolume correct <3> dVolume - dLotStep * MathFloor(dVolume/dLotStep) = 0.01000000 - 0.01000000 * MathFloor(0.01000000/0.01000000) = 0 <2> dVolume correct <2> MathMod(0.01000000,0.01000000)=0 <1> dVolume correct <1> MathMod(0.01000000,0.01000000)=0 inputs: dVolume=0.01; <3> dVolume incorrect <3> dVolume - dLotStep * MathFloor(dVolume/dLotStep) = 0.12300000 - 0.01000000 * MathFloor(0.12300000/0.01000000) = 0.003 <2> dVolume incorrect <2> MathMod(0.12300000,0.01000000)=0.003 <1> dVolume incorrect <1> MathMod(0.12300000,0.01000000)=0.003 inputs: dVolume=0.123; <3> dVolume correct <3> dVolume - dLotStep * MathFloor(dVolume/dLotStep) = 0.10000000 - 0.01000000 * MathFloor(0.10000000/0.01000000) = 0 <2> dVolume incorrect <2> MathMod(0.10000000,0.01000000)=0 <1> dVolume incorrect <1> MathMod(0.10000000,0.01000000)=0 inputs: dVolume=0.1; */ |
|
Testing Visualization: Functionality Enhancement The article describes software that can make strategy testing highly similar to the real trading. |
|
fbj
2008.10.30 16:40
i then put brackets around my HACK to highlight wat would expect operator precedence to be doing anyways and get strange result? wat up with if condition evaluation code in MQL4 ? . <5> dVolume incorrect BUT is not * higher precedence than - ? meaning using "(..)" should not make any differecne to outcome of expresion and so it appears below BUT wat is if condition evaluation code doing???? ZERO is FALSE, yes? so why if seeing TRUE ie, !=0 ?? . <5> dVolume incorrect |
|
phy
2008.10.30 18:03
Perhaps you are bumping into "known problems" with the imprecision of binary representations of floating point numbers... |
|
fbj
2008.10.30 18:30
please explain in simple terms. thankyou. i not 'get' wat u on about or how relate to simple demonstrated inconsistency in how expression evaluates to ZERO in one statement but decides NOT ZERO in if condition expresion evaluation - that not consistent is it? . i and code/print see ZERO and if condition sees non ZERO sorry, but not see how this relate to imprecision of anything but interpreter. if this is known problem then why no response from support? i not get any of this. 1. print ok 2. if evaluation not ok so wat to do with known problems or imprecision? . ok... maybe best i do own Mod(a,b) = a-b*floor(a/b) but this not issue is it? all revolves around the if condition - stuff inside (...) is expresion. stuff on own in statement is expresion - wat diff? both expresions... not get it. . as u see, ZERO is printed then magically, if condition not see ZERO . again, not see how anything do with your comment thank you for help? but this go nowheres fast i think . strange on support? silence - they gurus, i only asking for 'ultimate' ruling and solution/workaround/watevr, not care - just want genrl fix so all code work ok. . is this to much ask??? |
5089 |
stringo
2008.10.30 19:34
Once more http://docs.mql4.com/common/Print "Data of double type are printed with 4 decimal digits after point. To output more precisely, use the DoubleToStr() function." You can use our DoubleToStrMorePrecision from our stdlib. Also see as example CompareDoubles function in our stdlib. "strange on support"... try to find "compare doubles" - this subject is discussed every month. |
|
phy
2008.10.30 19:35
"if this is known problem then why no response from support" (1) This is known problem of Computer Science, not MQL. (2) Moderators have stated in the past this is "Community Forum" not specifically "Product Support Forum" I suggest you convert your values to integers for comparison in this case. |
|
fbj
2008.10.30 19:55
ok, dblmoreprecision, computer science, community forum - both ur times - thanks |