Rob Spoor wrote:There's also a method Math.pow which takes two doubles. You could use that if the exponent is a fraction other than 0.5.

. . . or 0.3333333333333333333333333333333333333333333 because there is a cube root method too.
Don't use Math,pow(x, 2) for squares. Use x * x instead.

Juan Villena
Greenhorn

Joined: Aug 27, 2011
Posts: 20

posted

0

Jesper the jonq, actually , i want to square root the whole equation, an\d is 331

Rob Spoor and Campbell Ritchie: so can i use math.pow in this particular ecuation or just math.sqrt
and can you tell if this is right or wrong : 331*(math.sqrt((t*273)/273) or can you guys write this ecuation using math class please.

If you want the square root of the whole equation, then you should obviously put the whole equation between the brackets for the method call to Math.sqrt:

So, Math.sqrt(331 * ...) and not 331 * Math.sqrt(...)

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41863

63

posted

0

What is the difference between "t" and "(t*273)/273" ? Is that intentional?

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38851

23

posted

0

I think Jesper has seen the error and inadvertently corrected it from * to +. With 273 in, probably something to do with absolute temperatures.

Beware of integer arithmetic: for any t such that t < 273 and t ≥ 0, the result of the division will turn out to be 1, if t is an integer.

Juan Villena
Greenhorn

Joined: Aug 27, 2011
Posts: 20

posted

0

Thanks a lot, I understand now...about Math.class... But my doubt is about the exponent ' 1/2 '. Using the same equation, if I want to elevated it to exponent 1/2, what Math.class should I use n which one is the correct one.
Math.sqrt or Math.pow ??