Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: How to manipulate integer that sometimes Nan and sometimes have a value? Date: Sat, 26 Sep 2015 14:43:22 +0200 Organization: PointedEars Software (PES) Lines: 44 Message-ID: <3550184.eD00NEl37L@PointedEars.de> References: <9060ce04-2f9e-4554-be83-2f69c213424f@googlegroups.com> <4f31ec16-109f-43b2-9d50-b39d4fb47f84@googlegroups.com> <3cf46737-de54-489e-9d9d-89413b18c099@googlegroups.com> <87wpvdec2d.fsf@bsb.me.uk> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1443271403 28449 eJwNwoENwDAIA7CXikYyek7Cyv8ndJbxMNhvEkwMJsfM+kd97rNxtuEuLytET8g5YsxRW+sCLq4Scw== (26 Sep 2015 12:43:23 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 26 Sep 2015 12:43:23 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwQkBwDAIA0BL0IRPzkrBv4TdGVy9g25OW9vaSaM4DkQgzqr3PlT1zQw5CwkGgnkZ+3rMR5s6KFmN+QEdyRRa Cancel-Lock: sha1:sL+aFxSgSsS8uEm4EpGZBKtL5xs= X-NNTP-Posting-Host: eJwFwYEBwCAIA7CXqtAi52wg/59gQtNShYtyDicVbRoTGmfy9o/aOUGGkC7zs+vyw/IetD8NeBCC Xref: csiph.com comp.lang.javascript:28725 Ben Bacarisse wrote: > jonas.thornvall@gmail.com writes: >> Den lördag 26 september 2015 kl. 00:11:31 UTC+2 skrev Danny: >>> in short, if the value is an integer, it will never return NaN. >>> What if may be happening in your case, is that the object gets >>> something else other than a numeric value. >>> >>> but a solution depends on what the context for all that is >>> and you haven't given us context or relevant code of the matter >> >> Well sometimes the index of the array is empty for the leading >> position, it is an carry operation. It is not the index that is "empty" then, but the array element. The index is a number used for addressing the elements of an array instead. > As yet unassigned positions in an array are undefined but the isNaN > function returned true for undefined values. It's likely that you don't > have a numeric NaN in addOne[i], but undefined instead. The Number.isNaN() method of ECMAScript Ed. 6 can solve this problem. It can be emulated as follows: if (typeof Number.isNaN != "function") { Number.isNaN = function (value) { return (typeof value == "number") && (value != value); }; } This makes use of the fact that the IEEE 754 “Not-a-number” value is the only Number value that is not equal to itself by definition. See also, and compare: PointedEars -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.