Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-12-2006, 02:01 PM
Q0paz Q0paz is offline
Junior Member
 
Join Date: Sep 2006
Posts: 9
Q0paz is on a distinguished road
Reciprocal

I am not the greatest mathematician but I have some functions I am converting from easy language that use the reciprocal of a number to provide a multiplyer in another function.

double method (int pwr)
{
double frac=0;

frac=1/pwr;

dootherstuffwith frac
}

However when I Print this the expression 1/pwr comes out as zero. I am doing binary progression stuff so all the numbers are of the series 1, 2, 4, 8, 16 etc. I can't see what I am doing wrong. I can't see a math.reciprocal function. Short of doing a pseudo lookup function ;

if(pwr = 2)
return(.5);
if(pwr = 4)
return(.25);
etc etc

any ideas ????

Thanks

Paz

Last edited by Q0paz : 11-13-2006 at 10:30 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-12-2006, 05:19 PM
omelette omelette is offline
Senior Member
 
Join Date: Jan 2006
Posts: 985
omelette is on a distinguished road
Hi. You need to define the '1' as a variable, type double, first - ie.

double method (int pwr)
{
double frac=0,temp;
temp = 1;
frac=temp/pwr;

dootherstuffwith frac
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-12-2006, 10:48 PM
Q0paz Q0paz is offline
Junior Member
 
Join Date: Sep 2006
Posts: 9
Q0paz is on a distinguished road
It would be very helpful if you could explain why that is the case. But in any case, thanks very much.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-12-2006, 11:25 PM
Nicholishen's Avatar
Nicholishen Nicholishen is offline
Senior Member
 
Join Date: Dec 2005
Posts: 531
Nicholishen is on a distinguished road
Quote:
Originally Posted by Q0paz
It would be very helpful if you could explain why that is the case. But in any case, thanks very much.
because when you devide an integer by an integer the value is expressed as an integr with a remainder, not the fractional value.
__________________
"Anyone who has never made a mistake has never tried anything new." -Albert Einstein
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-13-2006, 09:16 AM
Q0paz Q0paz is offline
Junior Member
 
Join Date: Sep 2006
Posts: 9
Q0paz is on a distinguished road
Ahhh ! Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump



All times are GMT. The time now is 12:08 AM.