W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2012

Re: Math method to calculate root for arbitrary exponent (e.g. cube root)

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Sun, 29 Jan 2012 19:21:51 -0800
Message-ID: <CABZUbM3op1NdhmWJ5pHYQhtoPcyoLHg=4LXmL_X8hJkyzLP0gQ@mail.gmail.com>
To: Cameron McCormack <cam@mcc.id.au>
Cc: "Marat Tanalin | tanalin.com" <mtanalin@yandex.ru>, public-script-coord@w3.org
On 1/29/12, Cameron McCormack <cam@mcc.id.au> wrote:
> Marat Tanalin:
>> It would be nice to have a standard method to calculate arbitrary root
>> (e.g. cube root).
>
> This seems to be a pure ECMAScript enhancement request, so I would
> suggest raising it on the es-discuss mailing list:
>
I agree. I'm not that good at math, but for fun:

function getCubeRoot(x) {
  if(x < 0) {
    return -Math.pow(-x, 1/3);
  }
  return  Math.pow(x, 1/3);
}
-- 
Garrett
Twitter: @xkit
personx.tumblr.com
Received on Monday, 30 January 2012 03:22:27 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:05 UTC