/* Integer part of mantissa */
{
char *int_buf = js_malloc(ctx, (size_t)digits_before + 1);
+ int n;
if (!int_buf) goto sci_fail;
- memcpy(int_buf, mv->digits, (size_t)digits_before);
- int_buf[digits_before] = '\0';
+ n = min_int(digits_before, mv->num_digits);
+ memcpy(int_buf, mv->digits, n);
+ while (n < digits_before)
+ int_buf[n++] = '0';
+ int_buf[n] = '\0';
dbuf_putstr(&db, int_buf);
if (!JS_IsUndefined(parts))
nf_add_part(ctx, parts, "integer", int_buf);
assert(new Intl.NumberFormat('en', { style: 'percent' }).format(0.5), "50%", "en percent");
assert(new Intl.NumberFormat('en', { style: 'currency', currency: 'EUR' }).format(1234.56),
"€1,234.56", "en EUR currency");
-
+ assert(new Intl.NumberFormat("en", { notation: "engineering" }).format(1e23), "100E21");
+
// de
assert(new Intl.NumberFormat('de').format(1234567.89), "1.234.567,89", "de number");
assert(new Intl.NumberFormat('de').format(1000000), "1.000.000", "de grouping");