MathPow Function

 

Hi this MathPow function keeps showing as 0, ideas? the negitive value is 

MathPow(2.71828,-B/A);
 

12345abc22: Hi this MathPow function keeps showing as 0, ideas? the negitive value is 

MathPow(2.71828,-B/A);

Your information is insufficient to reach a conclusion. What are the values of "B" and "A" when it shows a result of 0?

 
12345abc22:

Hi this MathPow function keeps showing as 0, ideas? the negitive value is 

If you put a -ve value for the power you are computing a smaller value - if B/A is a large negative value the result will be very small, even 0

Example:

   PrintFormat("MathPow(2.71828,  5)   = %.5f", MathPow(2.71828, 5));
   PrintFormat("MathPow(2.71828, -5)   = %.5f", MathPow(2.71828, -5));
   PrintFormat("MathPow(2.71828, -50)  = %.5f", MathPow(2.71828, -50));

Result:

2022.08.19 17:32:13.999 MathPow(2.71828,  5)   = 148.41266

2022.08.19 17:32:13.999 MathPow(2.71828, -5)   = 0.00674

2022.08.19 17:32:13.999 MathPow(2.71828, -50)  = 0.00000


 
12345abc22:

Hi this MathPow function keeps showing as 0, ideas? the negitive value is 

as 0

What are you doing with "e"?
I suppose you are using integers as A and B. This division will result most probably in 0 as you are doing something like e to the power of - A over B, and A as well as B will most probably be natural numbers.

So, A and B you most probably store in "int" variables. A division with a result below 1.0 will give you an integer of "0".

You need to change your code as follows, if my assumption is correct.

MathPow(2.71828,-B/(double)A);
Since you are referencing Euler's number, you can use a predefined constant.

MathPow(M_E, -B/(double)A);


 
@Dominik Christian Egert #: as . What are you doing with "e"? I suppose you are using integers as A and B. This division will result most probably in 0 as you are doing something like e to the power of - A over B, and A as well as B will most probably be natural numbers. So, A and B you most probably store in "int" variables. A division with a result below 1.0 will give you an integer of "0". You need to change your code as follows, if my assumption is correct.
If one were to assume integer division causing a result of 0 for -B/A, then the result of MathPow, namely e^0, would be 1.0 and not 0.0.
 
Fernando Carreiro #:
If one were to assume integer division causing a result of 0 for -B/A, then the result of MathPow, namely e^0, would be 1.0 and not 0.0.
Oh, yes, right...

Damn, I skipped.

Supposedly, the result is being saved in an "int" as well...

Edit:

I pointed out that anything to the pow of 0 would result in 1 in another post...




 
Dominik Christian Egert #:
Oh, yes, right...

Damn, I skipped.

Supposedly, the result is being saved in an "int" as well...

Edit:

I pointed out that anything to the pow of 0 would result in 1 in another post...





thanks for the reply guys, i already worked this out myself, i have another question about mean equation on another thread.

Reason: