Erik Davies

Greenhorn

Posts: 4

posted 2 years ago

here is all my code for a class i'm working on for a class below, but i'm having a issue with getDistanceFromMethod()

is there another way to rewrite this method without using the Math.pow? cause the second argument cant be a negative integer.

Its really got me stuck.

Thank you in advance,

Erik

is there another way to rewrite this method without using the Math.pow? cause the second argument cant be a negative integer.

Its really got me stuck.

Thank you in advance,

Erik

Piet Souris

Master Rancher

Posts: 2044

75

posted 2 years ago

remeber that a^(-b) is the same as 1/(a^b). So if you have a negative exponent, treat it like it is positive, then take the reciprocal.

Erik Davies wrote:is there another way to rewrite this method without using the Math.pow? cause the second argument cant be a negative integer.

remeber that a^(-b) is the same as 1/(a^b). So if you have a negative exponent, treat it like it is positive, then take the reciprocal.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors