Overloaded function not returning expected value

To add comments, please log in or register
imamushroom
289
imamushroom  

Hello,

I have the following overloaded function:

double normalize(const double price,const bool normalized)
  {
   return normalize(price,normalized,0);
  }

double normalize(const double price,const bool normalized,const int digits_delta)
  {
   double value=0.0;

   if(normalized)
     {
      const int digits=(int)_Digits+digits_delta;
      value=NormalizeDouble(price,digits);
     }

   return value;
  }

But when I call it using the following command:

   PrintFormat("normalize=%f",normalize(123.456,false));

I get 0.0000000 returned and I can't see why.

Could someone hightlight my error. 

Thanks in advance.

Sergey Genikhov
1665
Sergey Genikhov  
imamushroom:

Hello,

I have the following overloaded function:

But when I call it using the following command:

I get 0.0000000 returned and I can't see why.

Could someone hightlight my error. 

Thanks in advance.

What do you expect to recieve? "0.0"?
imamushroom
289
imamushroom  
Sergey Genikhov:
What do you expect to recieve? "0.0"?

No, I expect to get 123.456.

Mladen Rakic
136281
Mladen Rakic  
imamushroom:

Hello,

I have the following overloaded function:

But when I call it using the following command:

I get 0.0000000 returned and I can't see why.

Could someone hightlight my error. 

Thanks in advance.

if(normalized)
     {
     }

it will return value different from 0 only if you use true for normalized parameter

imamushroom
289
imamushroom  
Mladen Rakic:

it will return value different from 0 only if you use true for normalized parameter

Thank you.

I should have put 

   double value=price;

in the first place. Silly little error!

Thanks again.

To add comments, please log in or register