Skip to content

Commit

Permalink
Deploying to gh-pages from @ 6c9339e 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Apr 6, 2024
1 parent bcee98a commit 42c066e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ul></div><div id="menu-toggle"><svg xmlns="http://www.w3.org/2000/svg" style="width:100%; height:100%; stroke:currentColor" viewBox="0 0 120 120">
<title>Menu</title>
<path stroke-width="10" stroke-linecap="round" d="M30,60 h60 M30,30 m0,5 h60 M30,90 m0,-5 h60"></path>
</svg></div><div id="menu-spacer" class="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins<button class="unpin-all">clear</button></div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-proposal-intro" title="Introduction"><span class="secnum">1</span> Introduction</a></li><li><span class="item-toggle-none"></span><a href="#sec-math.sumexact" title="Math.sumExact ( items )"><span class="secnum">2</span> Math.sumExact ( <var>items</var> )</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 2 Draft / March 29, 2024</h1><h1 class="title">Math.sumExact</h1>
</svg></div><div id="menu-spacer" class="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins<button class="unpin-all">clear</button></div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-proposal-intro" title="Introduction"><span class="secnum">1</span> Introduction</a></li><li><span class="item-toggle-none"></span><a href="#sec-math.sumexact" title="Math.sumExact ( items )"><span class="secnum">2</span> Math.sumExact ( <var>items</var> )</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 2 Draft / April 6, 2024</h1><h1 class="title">Math.sumExact</h1>

<div id="metadata-block">
<h1>Contributing to this Proposal</h1>
Expand All @@ -27,6 +27,6 @@ <h1><span class="secnum">1</span> Introduction</h1>
<h1><span class="secnum">2</span> Math.sumExact ( <var>items</var> )</h1>
<p>Given an iterable of Numbers, this function sums each value in the iterable and returns their sum. If any value <emu-xref href="#sec-ecmascript-language-types-number-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-number-type">is not a Number</a></emu-xref> it throws a <emu-val>TypeError</emu-val> exception.</p>
<p>It performs the following steps when called:</p>
<emu-alg><ol><li>Perform ?&nbsp;<emu-xref aoid="RequireObjectCoercible"><a href="https://tc39.es/ecma262/#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>items</var>).</li><li>Let <var>iteratorRecord</var> be ?&nbsp;<emu-xref aoid="GetIterator"><a href="https://tc39.es/ecma262/#sec-getiterator">GetIterator</a></emu-xref>(<var>items</var>, <emu-const>sync</emu-const>).</li><li>Let <var>state</var> be <emu-const>minus-zero</emu-const>.</li><li>Let <var>sum</var> be 0.</li><li>Let <var>count</var> be 0.</li><li>Let <var>next</var> be <emu-const>not-started</emu-const>.</li><li>Repeat, while <var>next</var> is not <emu-const>done</emu-const>,<ol><li>Set <var>next</var> to ?&nbsp;<emu-xref aoid="IteratorStepValue"><a href="https://tc39.es/ecma262/#sec-iteratorstepvalue">IteratorStepValue</a></emu-xref>(<var>iteratorRecord</var>).</li><li>If <var>next</var> is not <emu-const>done</emu-const>, then<ol><li>Set <var>count</var> to <var>count</var> + 1.</li><li>If <var>count</var> ≥ 2<sup>53</sup>, then<ol><li>Let <var>error</var> be <emu-xref aoid="ThrowCompletion"><a href="https://tc39.es/ecma262/#sec-throwcompletion">ThrowCompletion</a></emu-xref>(a newly created <emu-val>RangeError</emu-val> object).</li><li>Return ?&nbsp;<emu-xref aoid="IteratorClose"><a href="https://tc39.es/ecma262/#sec-iteratorclose">IteratorClose</a></emu-xref>(<var>iteratorRecord</var>, <var>error</var>).</li></ol></li><li>NOTE: The above case is not expected to be reached in practice and is included only so that implementations may rely on inputs being "reasonably sized" without violating this specification.</li><li>If <var>next</var> is not a number, then<ol><li>Let <var>error</var> be <emu-xref aoid="ThrowCompletion"><a href="https://tc39.es/ecma262/#sec-throwcompletion">ThrowCompletion</a></emu-xref>(a newly created <emu-val>TypeError</emu-val> object).</li><li>Return ?&nbsp;<emu-xref aoid="IteratorClose"><a href="https://tc39.es/ecma262/#sec-iteratorclose">IteratorClose</a></emu-xref>(<var>iteratorRecord</var>, <var>error</var>).</li></ol></li><li>Let <var>n</var> be <var>next</var>.</li><li>If <var>state</var> is not <emu-const>not-a-number</emu-const>, then<ol><li>If <var>n</var> is <emu-val>NaN</emu-val>, set <var>state</var> to <emu-const>not-a-number</emu-const>.</li><li>If <var>n</var> is <emu-val>+∞</emu-val><sub>𝔽</sub>, then<ol><li>If <var>state</var> is <emu-const>minus-infinity</emu-const>, set <var>state</var> to <emu-const>not-a-number</emu-const>.</li><li>Else, set <var>state</var> to <emu-const>plus-infinity</emu-const>.</li></ol></li><li>If <var>n</var> is <emu-val>-∞</emu-val><sub>𝔽</sub>, then<ol><li>If <var>state</var> is <emu-const>plus-infinity</emu-const>, set <var>state</var> to <emu-const>not-a-number</emu-const>.</li><li>Else, set <var>state</var> to <emu-const>minus-infinity</emu-const>.</li></ol></li><li>If <var>n</var> is not <emu-val>-0</emu-val><sub>𝔽</sub> and <var>state</var> is either <emu-const>minus-zero</emu-const> or <emu-const>finite</emu-const>, then<ol><li>Set <var>state</var> to <emu-const>finite</emu-const>.</li><li>Set <var>sum</var> to <var>sum</var> + <emu-xref aoid="ℝ"><a href="https://tc39.es/ecma262/#ℝ">ℝ</a></emu-xref>(<var>n</var>).</li></ol></li></ol></li></ol></li></ol></li><li>If <var>state</var> is <emu-const>not-a-number</emu-const>, return <emu-val>NaN</emu-val>.</li><li>If <var>state</var> is <emu-const>plus-infinity</emu-const>, return <emu-val>+∞</emu-val><sub>𝔽</sub>.</li><li>If <var>state</var> is <emu-const>minus-infinity</emu-const>, return <emu-val>-∞</emu-val><sub>𝔽</sub>.</li><li>If <var>state</var> is <emu-const>minus-zero</emu-const>, return <emu-val>-0</emu-val><sub>𝔽</sub>.</li><li>Return <emu-xref aoid="𝔽"><a href="https://tc39.es/ecma262/#𝔽">𝔽</a></emu-xref>(<var>sum</var>).</li><li>NOTE: The value of <var>sum</var> can be computed without arbitrary-precision arithmetic by a variety of algorithms. One such is the "Grow-Expansion" algorithm given in <i>Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates</i> by Jonathan Richard Shewchuk. A more recent algorithm is given in "<a href="https://arxiv.org/abs/1505.05571">Fast exact summation using small and large superaccumulators</a>", code for which is available <a href="https://gitlab.com/radfordneal/xsum">here</a>.</li></ol></emu-alg>
<emu-alg><ol><li>Perform ?&nbsp;<emu-xref aoid="RequireObjectCoercible"><a href="https://tc39.es/ecma262/#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>items</var>).</li><li>Let <var>iteratorRecord</var> be ?&nbsp;<emu-xref aoid="GetIterator"><a href="https://tc39.es/ecma262/#sec-getiterator">GetIterator</a></emu-xref>(<var>items</var>, <emu-const>sync</emu-const>).</li><li>Let <var>state</var> be <emu-const>minus-zero</emu-const>.</li><li>Let <var>sum</var> be 0.</li><li>Let <var>count</var> be 0.</li><li>Let <var>next</var> be <emu-const>not-started</emu-const>.</li><li>Repeat, while <var>next</var> is not <emu-const>done</emu-const>,<ol><li>Set <var>next</var> to ?&nbsp;<emu-xref aoid="IteratorStepValue"><a href="https://tc39.es/ecma262/#sec-iteratorstepvalue">IteratorStepValue</a></emu-xref>(<var>iteratorRecord</var>).</li><li>If <var>next</var> is not <emu-const>done</emu-const>, then<ol><li>Set <var>count</var> to <var>count</var> + 1.</li><li>If <var>count</var> ≥ 2<sup>53</sup>, then<ol><li>Let <var>error</var> be <emu-xref aoid="ThrowCompletion"><a href="https://tc39.es/ecma262/#sec-throwcompletion">ThrowCompletion</a></emu-xref>(a newly created <emu-val>RangeError</emu-val> object).</li><li>Return ?&nbsp;<emu-xref aoid="IteratorClose"><a href="https://tc39.es/ecma262/#sec-iteratorclose">IteratorClose</a></emu-xref>(<var>iteratorRecord</var>, <var>error</var>).</li></ol></li><li>NOTE: The above case is not expected to be reached in practice and is included only so that implementations may rely on inputs being "reasonably sized" without violating this specification.</li><li>If <var>next</var> <emu-xref href="#sec-ecmascript-language-types-number-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-number-type">is not a Number</a></emu-xref>, then<ol><li>Let <var>error</var> be <emu-xref aoid="ThrowCompletion"><a href="https://tc39.es/ecma262/#sec-throwcompletion">ThrowCompletion</a></emu-xref>(a newly created <emu-val>TypeError</emu-val> object).</li><li>Return ?&nbsp;<emu-xref aoid="IteratorClose"><a href="https://tc39.es/ecma262/#sec-iteratorclose">IteratorClose</a></emu-xref>(<var>iteratorRecord</var>, <var>error</var>).</li></ol></li><li>Let <var>n</var> be <var>next</var>.</li><li>If <var>state</var> is not <emu-const>not-a-number</emu-const>, then<ol><li>If <var>n</var> is <emu-val>NaN</emu-val>, set <var>state</var> to <emu-const>not-a-number</emu-const>.</li><li>If <var>n</var> is <emu-val>+∞</emu-val><sub>𝔽</sub>, then<ol><li>If <var>state</var> is <emu-const>minus-infinity</emu-const>, set <var>state</var> to <emu-const>not-a-number</emu-const>.</li><li>Else, set <var>state</var> to <emu-const>plus-infinity</emu-const>.</li></ol></li><li>If <var>n</var> is <emu-val>-∞</emu-val><sub>𝔽</sub>, then<ol><li>If <var>state</var> is <emu-const>plus-infinity</emu-const>, set <var>state</var> to <emu-const>not-a-number</emu-const>.</li><li>Else, set <var>state</var> to <emu-const>minus-infinity</emu-const>.</li></ol></li><li>If <var>n</var> is not <emu-val>-0</emu-val><sub>𝔽</sub> and <var>state</var> is either <emu-const>minus-zero</emu-const> or <emu-const>finite</emu-const>, then<ol><li>Set <var>state</var> to <emu-const>finite</emu-const>.</li><li>Set <var>sum</var> to <var>sum</var> + <emu-xref aoid="ℝ"><a href="https://tc39.es/ecma262/#ℝ">ℝ</a></emu-xref>(<var>n</var>).</li></ol></li></ol></li></ol></li></ol></li><li>If <var>state</var> is <emu-const>not-a-number</emu-const>, return <emu-val>NaN</emu-val>.</li><li>If <var>state</var> is <emu-const>plus-infinity</emu-const>, return <emu-val>+∞</emu-val><sub>𝔽</sub>.</li><li>If <var>state</var> is <emu-const>minus-infinity</emu-const>, return <emu-val>-∞</emu-val><sub>𝔽</sub>.</li><li>If <var>state</var> is <emu-const>minus-zero</emu-const>, return <emu-val>-0</emu-val><sub>𝔽</sub>.</li><li>Return <emu-xref aoid="𝔽"><a href="https://tc39.es/ecma262/#𝔽">𝔽</a></emu-xref>(<var>sum</var>).</li><li>NOTE: The value of <var>sum</var> can be computed without arbitrary-precision arithmetic by a variety of algorithms. One such is the "Grow-Expansion" algorithm given in <i>Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates</i> by Jonathan Richard Shewchuk. A more recent algorithm is given in "<a href="https://arxiv.org/abs/1505.05571">Fast exact summation using small and large superaccumulators</a>", code for which is available <a href="https://gitlab.com/radfordneal/xsum">here</a>.</li></ol></emu-alg>
</emu-clause>
</div></body>

0 comments on commit 42c066e

Please sign in to comment.