You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
// 4. If the value of the numberFormat.[[numberingSystem]] matches one of the values in the "Numbering System" column of Table 2 below, then
539
-
if(numSys[nums]){
540
-
// a. Let digits be an array whose 10 String valued elements are the UTF-16 string representations of the 10 digits specified in the "Digits" column of the matching row in Table 2.
541
-
letdigits=numSys[nums];
542
-
// a. Replace each digit in n with the value of digits[digit].
543
-
n=String(n).replace(/\d/g,(digit)=>{
544
-
returndigits[digit];
545
-
});
546
-
}
547
-
// 5. Else use an implementation dependent algorithm to map n to the appropriate representation of n in the given numbering system.
548
-
elsen=String(n);// ###TODO###
549
-
550
-
letinteger;
551
-
letfraction;
552
-
// 6. Let decimalSepIndex be Call(%StringProto_indexOf%, n, ".", 0).
553
-
letdecimalSepIndex=n.indexOf('.',0);
554
-
// 7. If decimalSepIndex > 0, then:
555
-
if(decimalSepIndex>0){
556
-
// a. Let integer be the substring of n from position 0, inclusive, to position decimalSepIndex, exclusive.
557
-
integer=n.substring(0,decimalSepIndex-1);
558
-
// a. Let fraction be the substring of n from position decimalSepIndex, exclusive, to the end of n.
// 4. If the value of the numberFormat.[[numberingSystem]] matches one of the values in the "Numbering System" column of Table 2 below, then
539
+
if(numSys[nums]){
540
+
// a. Let digits be an array whose 10 String valued elements are the UTF-16 string representations of the 10 digits specified in the "Digits" column of the matching row in Table 2.
541
+
letdigits=numSys[nums];
542
+
// a. Replace each digit in n with the value of digits[digit].
543
+
n=String(n).replace(/\d/g,(digit)=>{
544
+
returndigits[digit];
545
+
});
546
+
}
547
+
// 5. Else use an implementation dependent algorithm to map n to the appropriate representation of n in the given numbering system.
548
+
elsen=String(n);// ###TODO###
549
+
550
+
letinteger;
551
+
letfraction;
552
+
// 6. Let decimalSepIndex be Call(%StringProto_indexOf%, n, ".", 0).
553
+
letdecimalSepIndex=n.indexOf('.',0);
554
+
// 7. If decimalSepIndex > 0, then:
555
+
if(decimalSepIndex>0){
556
+
// a. Let integer be the substring of n from position 0, inclusive, to position decimalSepIndex, exclusive.
557
+
integer=n.substring(0,decimalSepIndex);
558
+
// a. Let fraction be the substring of n from position decimalSepIndex, exclusive, to the end of n.
@@ -704,7 +704,6 @@ export function FormatNumber(numberFormat, x) {
704
704
// 2. Let result be an empty String.
705
705
letresult='';
706
706
// 3. For each part in parts, do:
707
-
console.log(parts);
708
707
for(letidxinparts){
709
708
letpart=parts[idx];
710
709
// a. Set result to a String value produced by concatenating result and part.[[value]].
@@ -805,8 +804,7 @@ function ToRawFixed(x, minInteger, minFraction, maxFraction) {
805
804
// 1. Let f be maxFraction.
806
805
letf=maxFraction;
807
806
// 2. Let n be an integer for which the exact mathematical value of n ÷ 10f – x is as close to zero as possible. If there are two such n, pick the larger n.
808
-
letp=Math.pow(10,f)*x;// ###TODO: add description for this variable p
809
-
letn=p>Math.floor(p) ? Math.round(p) : p+1;
807
+
letn=Math.round(Math.pow(10,f)*x);
810
808
// 3. If n = 0, let m be the String "0". Otherwise, let m be the String consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
811
809
letm=(n===0 ? "0" : (n+'').split('.')[0]);
812
810
@@ -825,7 +823,7 @@ function ToRawFixed(x, minInteger, minFraction, maxFraction) {
825
823
k=f+1;
826
824
}
827
825
// a. Let a be the first k–f characters of m, and let b be the remaining f characters of m.
0 commit comments