Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: How would you prepare for javascripting interview? Date: Mon, 05 Sep 2016 00:06:58 +0100 Organization: A noiseless patient Spider Lines: 45 Message-ID: <87h99vz2lp.fsf@bsb.me.uk> References: <50e38667-93da-4c5d-bc02-a78394f0ca3b@googlegroups.com> <1875389.irdbgypaU6@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="23614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CiXWep2/azz5QOfh/d1SzTBlwi5Ahp1c=" Cancel-Lock: sha1:Wq0wsPxoVb/sA1J8Qys5xNY8Iqg= sha1:MLTCDY4KOyp4c8thI+q5BP6wH84= X-BSB-Auth: 1.d595d2a4ced3a17f66e4.20160905000658BST.87h99vz2lp.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:31229 ram@zedat.fu-berlin.de (Stefan Ram) writes: > Doc O'Leary writes: >>They'll have to do worse if they expect to function correctly based >>on the current behavior. You could perhaps raise it as an exception >>if you prefer, but it's just plain *wrong* to return a number that >>wasn't given to you. > > |> 5 ** 0 > |< 1 > > Why does it evaluate to 1? > > 5³ = 5 · 5 · 5 = 125 > > 5² = 5 · 5 = 25 > > 5¹ = 5 = 5 > > 5° = = 1, why?? Lots of reasons... you want 5**x to be continuous (for real x)... you want 5**a x 5**b = 5 ** (a+b)... and so on. > There were three operands in the multiplication in the case of »5³«, > there were two operands in the multiplication in the case of »5²«, > there was still one number ("operand") left in the case of »5¹«, > but there is /no/ operand in the case of »5°«, so why is it 1? Here I think you want to draw attention to the fact that 1 is the multiplicative identity... > When you find the answer to this riddle, > then you will also understand the reason for > > |> Math.max() > |< -Infinity ... and -Infinity is the "max identity". Is that your point? I don't think anyone is wondering *why* Math.max() = -Infinity so much as whether it should be anything at all. -- Ben.