Re: Re: Re: Math.sign vs ±0
On Mon, Nov 4, 2013 at 4:10 AM, Ingvar Stepanyan m...@rreverser.com wrote: Why can’t we do Uint64 class inside Math namespace to be used for all the 64-bit arithmetic operations? Like: var x = Math.Uint64(2); var y = Math.Uint64.fromString(“0x12345678abcdef01”); var z = x.mul(y); // or Math.Uint64.mul(x, y) var z_hi = z.hi; // highest 32-bit part var z_lo = z.lo; // lowest 32-bit part var z_val = Number(z); // or z.valueOf(), returns IEEE.754-compatible float64 number when possible (with highest possible precision, so no loss up to +-2^52) Such syntax looks not so “low-level” for JS devs, should be easily polyfilled by current engines and optimized by new ones. Please read and review the value types proposal http://wiki.ecmascript.org/doku.php?id=strawman:value_types which will eventually replace the current contents of value objects http://wiki.ecmascript.org/doku.php?id=strawman:value_objects Rick ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
RE: Re: Re: Math.sign vs ±0
That's strange. I believe I replied to different thread. Sorry. Sent from my Windows Phone From: Rick Waldron Sent: 04.11.2013 15:41 To: Ingvar Stepanyan Cc: es-discuss@mozilla.org Subject: Re: Re: Re: Math.sign vs ±0 On Mon, Nov 4, 2013 at 4:10 AM, Ingvar Stepanyan m...@rreverser.com wrote: Why can’t we do Uint64 class inside Math namespace to be used for all the 64-bit arithmetic operations? Like: var x = Math.Uint64(2); var y = Math.Uint64.fromString(“0x12345678abcdef01”); var z = x.mul(y); // or Math.Uint64.mul(x, y) var z_hi = z.hi; // highest 32-bit part var z_lo = z.lo; // lowest 32-bit part var z_val = Number(z); // or z.valueOf(), returns IEEE.754-compatible float64 number when possible (with highest possible precision, so no loss up to +-2^52) Such syntax looks not so “low-level” for JS devs, should be easily polyfilled by current engines and optimized by new ones. Please read and review the value types proposal http://wiki.ecmascript.org/doku.php?id=strawman:value_types which will eventually replace the current contents of value objects http://wiki.ecmascript.org/doku.php?id=strawman:value_objects Rick ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Re: Math.sign vs ±0
There's no particular reason not to do something like that, except: 1. It is not usable (see http://www.jroller.com/cpurdy/entry/the_seven_habits_of_highly1%23comment-1130764636000). 2. Math is becoming a dumping ground, as noted up-thread. 3. Polyfillability is not important if old code can hand-code for better perf, and all evidence is that it can. Hacking JS into an uglier state for short-term illusory wins, not a good plan! /be Ingvar Stepanyan mailto:m...@rreverser.com November 4, 2013 1:10 AM Why can’t we do Uint64 class inside Math namespace to be used for all the 64-bit arithmetic operations? Like: var x = Math.Uint64(2); var y = Math.Uint64.fromString(“0x12345678abcdef01”); var z = x.mul(y); // or Math.Uint64.mul(x, y) var z_hi = z.hi; // highest 32-bit part var z_lo = z.lo; // lowest 32-bit part var z_val = Number(z); // or z.valueOf(), returns IEEE.754-compatible float64 number when possible (with highest possible precision, so no loss up to +-2^52) Such syntax looks not so “low-level” for JS devs, should be easily polyfilled by current engines and optimized by new ones. Regards, Ingvar Stepanyan. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss