Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28761
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How to manipulate integer that sometimes Nan and sometimes have a value? |
| Date | 2015-09-29 12:48 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87oaglcuoq.fsf@bsb.me.uk> (permalink) |
| References | (2 earlier) <3cf46737-de54-489e-9d9d-89413b18c099@googlegroups.com> <87wpvdec2d.fsf@bsb.me.uk> <64092fce-7ef7-48d7-9e0d-27a2220fcfe0@googlegroups.com> <87fv21dkmy.fsf@bsb.me.uk> <7a92063a-1369-4a31-ac81-1d69e0bf8ad8@googlegroups.com> |
jonas.thornvall@gmail.com writes: > Den lördag 26 september 2015 kl. 21:51:43 UTC+2 skrev Ben Bacarisse: <snip> >> ... An as yet >> unassigned array position is undefined -- it won't have NaN as its >> value. However, isNaN (the global function by that name) converts it's >> argument in such a way that undefined becomes NaN. >> >> $ nodejs >> > var a = []; >> undefined >> > a[1] >> undefined >> > a[1] === undefined >> true >> > isNaN(a[1]) >> >> This may be why you think you have NaN in the "extra" digit places. >> > > From what i understand an array, is a storage bin/stack of items. Now > i have a stack of items that in most case do have an initiated element > at index, but in some cases it is indeed empty. Your terminology is wrong. An array is not a stack and the metaphor of describing as yet unused elements as empty is leading you astray. They are nether full nor empty -- an expression that accesses an unknown property of an object has the value called undefined. That's a value like any other, and you can even assign it to an array element -- a[i] may have been set to undefined. > Since it is integer > elements i do perform opeations upon performing carry operations, i > think it is kind of weird that there is no good way to deal with this. There is a way to deal with this. You don't consider it a good way, but there's nothing that can be done about that. > This must be the most common problem programming statistics. I do not > see why i should not be able to add to an undefined value, it is > basicly like adding to zero. And since the type of the elements stored > are integers, i just can't see the point i have to do a check > everytime an assign a zero, it is ridiculous. A suggestion to fill the > slot ahead with zeroes do not work either because then the array > length will not report correct. Not everyone has the same view of what is ridiculous. I think what ECMAScript does here is perfectly sensible. > It is kind of strange that such operation report NaN back. It's a reasonably choice for the language designers to have made. You might prefer to switch to Perl. In Perl, undef() + 1 == 1 although it is considered bad style to rely on that fact. -- Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-25 07:31 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-25 17:09 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-25 14:43 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 08:54 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-09-30 15:04 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-30 21:13 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-10-01 10:44 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-10-01 13:56 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? John Harris <niam@jghnorth.org.uk.invalid> - 2015-10-02 11:09 +0100
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-02 13:55 +0100
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-10-02 16:34 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Danny <dann90038@gmail.com> - 2015-09-25 15:11 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-25 17:50 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 08:59 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-26 04:25 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 15:00 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-26 06:15 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 15:34 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-26 08:06 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Tim Streater <timstreater@greenbee.net> - 2015-09-26 18:10 +0100
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 22:53 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Tim Streater <timstreater@greenbee.net> - 2015-09-26 22:37 +0100
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-27 10:05 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-27 08:42 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Tim Streater <timstreater@greenbee.net> - 2015-09-27 17:18 +0100
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-26 10:59 +0100
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 13:15 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-26 14:58 +0100
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 16:57 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-26 04:28 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 15:11 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-26 17:19 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 22:51 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-27 13:50 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-26 20:51 +0100
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-28 22:45 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-29 12:36 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-29 12:48 +0100
Re: How to manipulate integer that sometimes Nan and sometimes have a value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-26 14:43 +0200
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-26 06:06 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? John Harris <niam@jghnorth.org.uk.invalid> - 2015-09-27 14:06 +0100
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-27 08:50 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-27 08:53 -0700
Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-27 09:02 -0700
csiph-web