Last active
April 30, 2021 21:28
-
-
Save steveluscher/4b54e08aa1e0536b7cb9 to your computer and use it in GitHub Desktop.
Revisions
-
steveluscher revised this gist
Feb 24, 2015 . No changes.There are no files selected for viewing
-
steveluscher revised this gist
Feb 24, 2015 . No changes.There are no files selected for viewing
-
steveluscher revised this gist
Feb 24, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -84,4 +84,4 @@ console.log(new Intl.NumberFormat('ja-JP', { abbreviationThreshold: 1e6, maximum <dd>Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.</dd> </dl> (_Prior art: http://docs.oracle.com/javase/7/docs/api/java/math/RoundingMode.html_) -
steveluscher revised this gist
Feb 24, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -82,4 +82,6 @@ console.log(new Intl.NumberFormat('ja-JP', { abbreviationThreshold: 1e6, maximum <dt>Intl.NumberFormat.ROUND_HALF_DOWN</dt> <dd>Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.</dd> </dl> (_Prior art: http://docs.oracle.com/javase/7/docs/api/java/math/RoundingMode.html) -
steveluscher revised this gist
Feb 24, 2015 . No changes.There are no files selected for viewing
-
steveluscher revised this gist
Feb 24, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,10 +51,10 @@ console.log(new Intl.NumberFormat('ja-JP', { abbreviationThreshold: 1e6, maximum … ``` ## Addendum <a name="roundingmodes"></a> ### Rounding modes <dl> <dt>Intl.NumberFormat.ROUND_CEILING</dt> <dd>Rounding mode to round towards positive infinity.</dd> -
steveluscher revised this gist
Feb 24, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,6 +51,8 @@ console.log(new Intl.NumberFormat('ja-JP', { abbreviationThreshold: 1e6, maximum … ``` ### Addendum <a name="roundingmodes"></a> #### Rounding modes <dl> -
steveluscher revised this gist
Feb 24, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,6 +44,8 @@ var number = 1234567.89; // abbreviate a number console.log(new Intl.NumberFormat('en-US', { abbreviationThreshold: 1e6, maximumSignificantDigits: 3 }).format(number)); // → 1.23M console.log(new Intl.NumberFormat('en-US', { abbreviationThreshold: 1e6, style: 'currency', maximumSignificantDigits: 3 }).format(number)); // → $1.23M console.log(new Intl.NumberFormat('ja-JP', { abbreviationThreshold: 1e6, maximumSignificantDigits: 3 }).format(number)); // → 123万 … -
steveluscher revised this gist
Feb 24, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Intl.NumberFormat.call(this[, locales[, options]]) <dd>Numbers whose absolute value is greater than this number will be abbreviated. Possible values are from <code>0</code> to <code>Infinity</code>; the default is <code>Infinity</code>, which effectively disables abbreviation.</dd> <dt>abbreviationRoundingMethod</dt> <dd>The rounding behavior to exhibit when abbreviating a number. Possible values are <code>Intl.NumberFormat.ROUND_CEILING</code>, <code>Intl.NumberFormat.ROUND_FLOOR</code>, <code>Intl.NumberFormat.ROUND_UP</code>, <code>Intl.NumberFormat.ROUND_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_EVEN</code>, and <code>Intl.NumberFormat.ROUND_HALF_UP</code>; the default is <code>Intl.NumberFormat.ROUND_HALF_CEILING</code>. For more information about rounding modes, see <a href="#roundingmodes">rounding modes</a>.</dd> … </dl> </dd> -
steveluscher revised this gist
Feb 24, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Intl.NumberFormat.call(this[, locales[, options]]) <dd>Numbers whose absolute value is greater than this number will be abbreviated. Possible values are from <code>0</code> to <code>Infinity</code>; the default is <code>Infinity</code>, which effectively disables abbreviation.</dd> <dt>abbreviationRoundingMethod</dt> <dd>The rounding behavior to exhibit when abbreviating a number. Possible values are <code class="highlight highlight-javascript">Intl.NumberFormat.ROUND_CEILING</code>, <code>Intl.NumberFormat.ROUND_FLOOR</code>, <code>Intl.NumberFormat.ROUND_UP</code>, <code>Intl.NumberFormat.ROUND_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_EVEN</code>, and <code>Intl.NumberFormat.ROUND_HALF_UP</code>; the default is <code>Intl.NumberFormat.ROUND_HALF_CEILING</code>. For more information about rounding modes, see <a href="#roundingmodes">rounding modes</a>.</dd> … </dl> </dd> -
steveluscher revised this gist
Feb 24, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Intl.NumberFormat.call(this[, locales[, options]]) <dd>Numbers whose absolute value is greater than this number will be abbreviated. Possible values are from <code>0</code> to <code>Infinity</code>; the default is <code>Infinity</code>, which effectively disables abbreviation.</dd> <dt>abbreviationRoundingMethod</dt> <dd>The rounding behavior to exhibit when abbreviating a number. Possible values are <code class="language-js">Intl.NumberFormat.ROUND_CEILING</code>, <code>Intl.NumberFormat.ROUND_FLOOR</code>, <code>Intl.NumberFormat.ROUND_UP</code>, <code>Intl.NumberFormat.ROUND_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_EVEN</code>, and <code>Intl.NumberFormat.ROUND_HALF_UP</code>; the default is <code>Intl.NumberFormat.ROUND_HALF_CEILING</code>. For more information about rounding modes, see <a href="#roundingmodes">rounding modes</a>.</dd> … </dl> </dd> -
steveluscher revised this gist
Feb 24, 2015 . 1 changed file with 12 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Intl.NumberFormat.call(this[, locales[, options]]) <dd>Numbers whose absolute value is greater than this number will be abbreviated. Possible values are from <code>0</code> to <code>Infinity</code>; the default is <code>Infinity</code>, which effectively disables abbreviation.</dd> <dt>abbreviationRoundingMethod</dt> <dd>The rounding behavior to exhibit when abbreviating a number. Possible values are <code>Intl.NumberFormat.ROUND_CEILING</code>, <code>Intl.NumberFormat.ROUND_FLOOR</code>, <code>Intl.NumberFormat.ROUND_UP</code>, <code>Intl.NumberFormat.ROUND_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_EVEN</code>, and <code>Intl.NumberFormat.ROUND_HALF_UP</code>; the default is Intl.NumberFormat.ROUND_HALF_CEILING. For more information about rounding modes, see <a href="#roundingmodes">rounding modes</a>.</dd> … </dl> </dd> @@ -63,13 +63,19 @@ console.log(new Intl.NumberFormat('ja-JP', { abbreviationThreshold: 1e6, maximum <dt>Intl.NumberFormat.ROUND_UP</dt> <dd>Rounding mode to round away from zero.</dd> <dt>Intl.NumberFormat.ROUND_HALF_CEILING</dt> <dd>Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards positive infinity.</dd> <dt>Intl.NumberFormat.ROUND_HALF_UP</dt> <dd>Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.</dd> <dt>Intl.NumberFormat.ROUND_HALF_EVEN</dt> <dd>Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.</dd> <dt>Intl.NumberFormat.ROUND_HALF_FLOOR</dt> <dd>Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards negative infinity.</dd> <dt>Intl.NumberFormat.ROUND_HALF_DOWN</dt> <dd>Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.</dd> </dl> -
steveluscher revised this gist
Feb 23, 2015 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -52,24 +52,24 @@ console.log(new Intl.NumberFormat('ja-JP', { abbreviationThreshold: 1e6, maximum <a name="roundingmodes"></a> #### Rounding modes <dl> <dt>Intl.NumberFormat.ROUND_CEILING</dt> <dd>Rounding mode to round towards positive infinity.</dd> <dt>Intl.NumberFormat.ROUND_FLOOR</dt> <dd>Rounding mode to round towards negative infinity.</dd> <dt>Intl.NumberFormat.ROUND_DOWN</dt> <dd>Rounding mode to round towards zero.</dd> <dt>Intl.NumberFormat.ROUND_UP</dt> <dd>Rounding mode to round away from zero.</dd> <dt>Intl.NumberFormat.ROUND_HALF_DOWN</dt> <dd>Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.</dd> <dt>Intl.NumberFormat.ROUND_HALF_EVEN</dt> <dd>Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.</dd> <dt>Intl.NumberFormat.ROUND_HALF_UP</dt> <dd>Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.</dd> </dl> -
steveluscher revised this gist
Feb 23, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,9 +42,9 @@ var number = 1234567.89; … // abbreviate a number console.log(new Intl.NumberFormat('en-US', { abbreviationThreshold: 1e6, maximumSignificantDigits: 3 }).format(number)); // → 1.23M console.log(new Intl.NumberFormat('ja-JP', { abbreviationThreshold: 1e6, maximumSignificantDigits: 3 }).format(number)); // → 123万 … ``` -
steveluscher revised this gist
Feb 23, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ ## Syntax ```javascript new Intl.NumberFormat([locales[, options]]) Intl.NumberFormat.call(this[, locales[, options]]) ``` -
steveluscher revised this gist
Feb 23, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,7 @@ Intl.NumberFormat.call(this[, locales[, options]]) The results can be customized using the options argument: ```javascript var number = 1234567.89; … @@ -47,6 +47,7 @@ console.log(new Intl.NumberFormat('en-US', { abbreviationThreshold: 1e5, maximum console.log(new Intl.NumberFormat('ja-JP', { abbreviationThreshold: 1e5, maximumSignificantDigits: 3 }).format(number)); // → 123万 … ``` <a name="roundingmodes"></a> #### Rounding modes -
steveluscher revised this gist
Feb 23, 2015 . 1 changed file with 21 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,17 +18,36 @@ Intl.NumberFormat.call(this[, locales[, options]]) <dl> … <dt>abbreviationThreshold</dt> <dd>Numbers whose absolute value is greater than this number will be abbreviated. Possible values are from <code>0</code> to <code>Infinity</code>; the default is <code>Infinity</code>, which effectively disables abbreviation.</dd> <dt>abbreviationRoundingMethod</dt> <dd>The rounding behavior to exhibit when abbreviating a number. Possible values are <code>Intl.NumberFormat.ROUND_CEILING</code>, <code>Intl.NumberFormat.ROUND_FLOOR</code>, <code>Intl.NumberFormat.ROUND_UP</code>, <code>Intl.NumberFormat.ROUND_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_EVEN</code>, and <code>Intl.NumberFormat.ROUND_HALF_UP</code>; the default is <mark>???</mark>. For more information about rounding modes, see <a href="#roundingmodes">rounding modes</a>.</dd> … </dl> </dd> </dl> … ## Examples … ### Example: Using `options` The results can be customized using the options argument: ``` var number = 1234567.89; … // abbreviate a number console.log(new Intl.NumberFormat('en-US', { abbreviationThreshold: 1e5, maximumSignificantDigits: 3 }).format(number)); // → 1.23M console.log(new Intl.NumberFormat('ja-JP', { abbreviationThreshold: 1e5, maximumSignificantDigits: 3 }).format(number)); // → 123万 … <a name="roundingmodes"></a> #### Rounding modes <dl> -
steveluscher revised this gist
Feb 23, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Intl.NumberFormat.call(this[, locales[, options]]) <dd>Numbers whose absolute value is greater than this number will be abbreviated. The default is <code>Infinity</code>, which effectively disables abbreviation.</dd> <dt>abbreviationRoundingMethod</dt> <dd>The rounding behavior to exhibit when abbreviating a number. Possible values are <code>Intl.NumberFormat.ROUND_CEILING</code>, <code>Intl.NumberFormat.ROUND_FLOOR</code>, <code>Intl.NumberFormat.ROUND_UP</code>, <code>Intl.NumberFormat.ROUND_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_EVEN</code>, and <code>Intl.NumberFormat.ROUND_HALF_UP</code>. For more information about rounding modes, see <a href="#roundingmodes">rounding modes</a>.</dd> … </dl> </dd> -
steveluscher revised this gist
Feb 23, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,10 +17,10 @@ Intl.NumberFormat.call(this[, locales[, options]]) <p>Optional. An object with some or all of the following properties:</p> <dl> … <dt>abbreviationThreshold</dt> <dd>Numbers whose absolute value is greater than this number will be abbreviated. The default is <code>Infinity</code>, which effectively disables abbreviation.</dd> <dt>abbreviationRoundingMethod</dt> <dd>The rounding behavior to exhibit when abbreviating a number. Possible values are <code>Intl.NumberFormat.ROUND_CEILING</code>, <code>Intl.NumberFormat.ROUND_FLOOR</code>, <code>Intl.NumberFormat.ROUND_UP</code>, <code>Intl.NumberFormat.ROUND_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_EVEN</code>, and <code>Intl.NumberFormat.ROUND_HALF_UP</code>. For more information about rounding modes, see <a href="#roundingmodes">LINK</a>.</dd> … </dl> -
steveluscher revised this gist
Feb 23, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ Intl.NumberFormat.call(this[, locales[, options]]) <dl> … <dt>abbreviateThreshold</dt> <dd>Numbers whose absolute value is greater than this number will be abbreviated. The default is <code>Infinity</code>, which effectively disables abbreviation.</dd> <dt>abbreviateRoundingMethod</dt> <dd>The rounding behavior to exhibit when abbreviating a number. Possible values are <code>Intl.NumberFormat.ROUND_CEILING</code>, <code>Intl.NumberFormat.ROUND_FLOOR</code>, <code>Intl.NumberFormat.ROUND_UP</code>, <code>Intl.NumberFormat.ROUND_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_EVEN</code>, and <code>Intl.NumberFormat.ROUND_HALF_UP</code>. For more information about rounding modes, see <a href="#roundingmodes">LINK</a>.</dd> -
steveluscher created this gist
Feb 23, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ # Intl.NumberFormat ## Syntax ``` new Intl.NumberFormat([locales[, options]]) Intl.NumberFormat.call(this[, locales[, options]]) ``` ### Parameters … <dl> <dt>options</dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> … <dt>abbreviateThreshold</dt> <dd>Numbers whose absolute value is greater than this number will be abbreviated. The default is <code>Infinity</code>.</dd> <dt>abbreviateRoundingMethod</dt> <dd>The rounding behavior to exhibit when abbreviating a number. Possible values are <code>Intl.NumberFormat.ROUND_CEILING</code>, <code>Intl.NumberFormat.ROUND_FLOOR</code>, <code>Intl.NumberFormat.ROUND_UP</code>, <code>Intl.NumberFormat.ROUND_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_DOWN</code>, <code>Intl.NumberFormat.ROUND_HALF_EVEN</code>, and <code>Intl.NumberFormat.ROUND_HALF_UP</code>. For more information about rounding modes, see <a href="#roundingmodes">LINK</a>.</dd> … </dl> </dd> </dl> … <a name="roundingmodes"></a> #### Rounding modes <dl> <dt>CEILING</dt> <dd>Rounding mode to round towards positive infinity.</dd> <dt>FLOOR</dt> <dd>Rounding mode to round towards negative infinity.</dd> <dt>DOWN</dt> <dd>Rounding mode to round towards zero.</dd> <dt>UP</dt> <dd>Rounding mode to round away from zero.</dd> <dt>HALF_DOWN</dt> <dd>Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.</dd> <dt>HALF_EVEN</dt> <dd>Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.</dd> <dt>HALF_UP</dt> <dd>Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.</dd> </dl>