Hello Daniweb,
What would you guys say is the most effective way to manage memory for powers?

I'm thinking for smaller powers, like squares or something, it's probably just better to do x * x and Math.pow(x, 2) should only be used for bigger powers.

I have a lot of those calculations in a single file so was just wondering what the best way to approach it would be.

Cheers!

Recommended Answers

All 2 Replies

Math.power ends up in a native method to do the actual calculation, so its a reasonable bet that's its very efficient indeed. Either way. memory really doesn't come into it.
Unless your idea of "a lot" runs into millions in this case, I wouldn't waste another millisec worrying about speed or memory for Math,power.

It for sure doesn't run into millions, but I do see your point with native functions v.s. external.

Cheers mate! Gonna mark this as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.