Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ecma 402 part of the spec #95

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
on: push
name: lint spec

jobs:
Expand All @@ -11,6 +12,10 @@ jobs:
uses: actions/checkout@v4

- name: Install ecmarkup
run: npm install --global ecmarkup

- run: npm install --global ecmarkup
- run: ecmarkup --lint-spec --strict spec.emu out.html
- name: lint main spec
run: ecmarkup --lint-spec --strict spec.emu spec.html

- name: lint intl spec
run: ecmarkup --lint-spec --strict intl-spec.emu intl-spec.html
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: all clean

all: spec.html

clean:
find . -type f -name '*~' -delete
find . -type f -name '.*~' -delete
find . -mindepth 1 -maxdepth 1 -type f -name '*.html' -delete

%.html: %.emu biblio.json
npx ecmarkup --lint-spec --load-biblio @tc39/ecma262-biblio --strict $< $@
58 changes: 58 additions & 0 deletions intl.emu
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!doctype html>
<meta charset="utf8">
<link rel="stylesheet" href="./spec.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="./spec.js"></script>
<pre class="metadata">
title: Decimal
status: proposal
stage: 1
contributors: Jesse Alama
location: https://github.com/tc39/proposal-decimal/
</pre>

<emu-clause id="sec-intl">
<h1>Scope</h1>
<p>
This is the spec text of the <a href="https://github.com/tc39/proposal-decimal/" title="Decimal proposal (GitHub)">Decimal proposal</a> in ECMAScript that bears on Ecma 402.
</p>
</emu-clause>

<emu-clause id="numberformat-objects">
<h1>15 NumberFormat Objects</h1>
<emu-clause id="sec-numberformat-abstracts">
<h1>15.5 Abstract Operations for NumberFormat Objects</h1>
<emu-clause id="sec-tointlmathematicalvalue" type="abstract operation">
<h1>ToIntlMathematicalValue (_value_)</h1>
<dl class="header">
<dt>description</dt>
<dd>
It returns _value_ converted to an <dfn id="intl-mathematical-value">Intl mathematical value</dfn>, which is a mathematical value together with ~positive-infinity~, ~negative-infinity~, ~not-a-number~, and ~negative-zero~.
This abstract operation is similar to <emu-xref href="#sec-tonumeric"></emu-xref>, but a mathematical value can be returned instead of a Number or BigInt, so that exact decimal values can be represented.
</dd>
</dl>
<emu-alg>
1. <ins>If _value_ is a Decimal128 object, return ℝ(_value_).</ins>
1. Let _primValue_ be ? ToPrimitive(_value_, ~number~).
1. If Type(_primValue_) is BigInt, return ℝ(_primValue_).
1. If Type(_primValue_) is String, then
1. Let _str_ be _primValue_.
1. Else,
1. Let _x_ be ? ToNumber(_primValue_).
1. If _x_ is *-0*<sub>𝔽</sub>, return ~negative-zero~.
1. Let _str_ be Number::toString(_x_, 10).
1. Let _text_ be StringToCodePoints(_str_).
1. Let _literal_ be ParseText(_text_, |StringNumericLiteral|).
1. If _literal_ is a List of errors, return ~not-a-number~.
1. Let _intlMV_ be the StringIntlMV of _literal_.
1. If _intlMV_ is a mathematical value, then
1. Let _rounded_ be RoundMVResult(abs(_intlMV_)).
1. If _rounded_ is *+∞*<sub>𝔽</sub> and _intlMV_ &lt; 0, return ~negative-infinity~.
1. If _rounded_ is *+∞*<sub>𝔽</sub>, return ~positive-infinity~.
1. If _rounded_ is *+0*<sub>𝔽</sub> and _intlMV_ &lt; 0, return ~negative-zero~.
1. If _rounded_ is *+0*<sub>𝔽</sub>, return 0.
1. Return _intlMV_.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
2 changes: 2 additions & 0 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,5 @@ location: https://github.com/tc39/proposal-decimal/
</emu-clause>
</emu-clause>
</emu-clause>

<emu-import href="intl.emu"></emu-import>
Loading