Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24763
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: "i = i|0" |
| Date | 2014-06-12 13:35 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <1897109.R5dzFez7A1@PointedEars.de> (permalink) |
| References | <emscripten-20140611221102@ram.dialup.fu-berlin.de> <5398d161$0$6667$9b4e6d93@newsspool3.arcor-online.net> <12993215.vN2ElCmnT9@PointedEars.de> <53998d6b$0$6613$9b4e6d93@newsspool4.arcor-online.net> |
Christoph Michael Becker wrote: > Thomas 'PointedEars' Lahn wrote: >> Christoph Michael Becker wrote: >>> At least the C semantics are better matched; consider arbitrary input to >>> the function, or an overflow occuring in the calculation. >>> >>> I'm not sure about the performance. Actually, this idiom is quite >>> common, so it might cause performance improvements in some ECMAScript >>> implementations. At least it is used in asm.js to enforce the type of i >>> and the return value to be an integer type. >> >> Unfortunately, you are wrong on all accounts. > > Even if I am wrong on all accounts, I wouldn't call that unfortunate--at > least I could learn from the mistake/misinformation. :) I would rather that you had not been wrong and this mistake by others had been discovered earlier. >> It would appear that at least this Emscripten version (probably asm.js, >> too) is yet another script-kiddie approach that should be avoided, at >> least for all computationally critical uses. > > I wouldn't call Emscripten/asm.js a script-kiddie approach. It seems > asm.js is already supported by all major browsers, and it seems that > there are areas of application where asm.js is mandatory for > performance, e.g. browser games. So much the worse. >> ToInt32(…) is _not_ equivalent to >> C/C++’s “int”. > > Of course. But if I'm not mistaken, there is no ToInt32() involved in > asm.js code, which instead deals with native "int"s. You are missing the point. Native “int”s are *generic*; the “|” algorithm is not. It matters not that asm.js does not use ToInt32(); Emscripten is used to transcompile to asm.js, and Emscripten apparently generates code that uses ToInt32() implicitly; namely, it uses the “|” operator for conversion to pseudo-integer. -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: "i = i|0" Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-12 00:00 +0200
Re: "i = i|0" Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-12 01:04 +0200
Re: "i = i|0" Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-12 13:22 +0200
Re: "i = i|0" Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-12 13:35 +0200
Re: "i = i|0" Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-12 15:26 +0200
csiph-web