Lines Matching full:-

2  *  Number-to-string and string-to-number conversions.
4 * Slow path number-to-string and string-to-number conversion is based on
10 * See: doc/number-conversion.rst.
16 #define DUK__IEEE_DOUBLE_EXP_MIN (-1022) /* biased exp == 0 -> denormal, exp -1022 */
24 * digits should be considered significant for string-to-number conversion.
28 * duk__str2num_exp_limits indicates, for each radix, the radix-specific
48 { 957, -1147 }, { 605, -725 }, { 479, -575 }, { 414, -496 },
49 { 372, -446 }, { 342, -411 }, { 321, -384 }, { 304, -364 },
50 { 291, -346 }, { 279, -334 }, { 268, -323 }, { 260, -312 },
51 { 252, -304 }, { 247, -296 }, { 240, -289 }, { 236, -283 },
52 { 231, -278 }, { 227, -273 }, { 223, -267 }, { 220, -263 },
53 { 216, -260 }, { 213, -256 }, { 210, -253 }, { 208, -249 },
54 { 205, -246 }, { 203, -244 }, { 201, -241 }, { 198, -239 },
55 { 196, -237 }, { 195, -234 }, { 193, -232 }, { 191, -230 },
56 { 190, -228 }, { 188, -226 }, { 187, -225 },
62 * Restricted to non-negative numbers with less than 32 * DUK__BI_MAX_PARTS bits,
68 * x <- y * z --> duk__bi_mul(x, y, z);
96 p += DUK_SPRINTF(p, "%p n=%ld", (void *) x, (long) x->n); in duk__bi_print()
97 if (x->n == 0) { in duk__bi_print()
100 for (i = x->n - 1; i >= 0; i--) { in duk__bi_print()
101 p += DUK_SPRINTF(p, " %08lx", (unsigned long) x->v[i]); in duk__bi_print()
111 ( ((x->n >= 0) && (x->n <= DUK__BI_MAX_PARTS)) /* is valid size */ && in duk__bi_is_valid()
112 ((x->n == 0) || (x->v[x->n - 1] != 0)) /* is normalized */ ); in duk__bi_is_valid()
119 for (i = x->n - 1; i >= 0; i--) { in duk__bi_normalize()
120 if (x->v[i] != 0) { in duk__bi_normalize()
125 /* Note: if 'x' is zero, x->n becomes 0 here */ in duk__bi_normalize()
126 x->n = i + 1; in duk__bi_normalize()
130 /* x <- y */
134 n = y->n; in duk__bi_copy()
135 x->n = n; in duk__bi_copy()
139 DUK_MEMCPY((void *) x->v, (const void *) y->v, (size_t) (sizeof(duk_uint32_t) * n)); in duk__bi_copy()
144 x->n = 0; in duk__bi_set_small()
146 x->n = 1; in duk__bi_set_small()
147 x->v[0] = v; in duk__bi_set_small()
163 nx = x->n; in duk__bi_compare()
164 ny = y->n; in duk__bi_compare()
171 for (i = nx - 1; i >= 0; i--) { in duk__bi_compare()
172 tx = x->v[i]; in duk__bi_compare()
173 ty = y->v[i]; in duk__bi_compare()
189 return -1; in duk__bi_compare()
192 /* x <- y + z */
201 if (z->n > y->n) { in duk__bi_add()
205 DUK_ASSERT(y->n >= z->n); in duk__bi_add()
207 ny = y->n; nz = z->n; in duk__bi_add()
211 tmp += y->v[i]; in duk__bi_add()
213 tmp += z->v[i]; in duk__bi_add()
215 x->v[i] = (duk_uint32_t) (tmp & 0xffffffffUL); in duk__bi_add()
220 x->v[i++] = (duk_uint32_t) tmp; in duk__bi_add()
222 x->n = i; in duk__bi_add()
223 DUK_ASSERT(x->n <= DUK__BI_MAX_PARTS); in duk__bi_add()
236 if (z->n > y->n) { in duk__bi_add()
240 DUK_ASSERT(y->n >= z->n); in duk__bi_add()
242 ny = y->n; nz = z->n; in duk__bi_add()
245 /* Carry is detected based on wrapping which relies on exact 32-bit in duk__bi_add()
249 tmp1 = y->v[i]; in duk__bi_add()
252 tmp2 += z->v[i]; in duk__bi_add()
256 * - If carry not added: 0x12345678 + 0 + 0xffffffff = 0x12345677 (< 0x12345678) in duk__bi_add()
257 * - If carry added: 0x12345678 + 1 + 0xffffffff = 0x12345678 (== 0x12345678) in duk__bi_add()
266 x->v[i] = tmp2; in duk__bi_add()
271 x->v[i++] = carry; in duk__bi_add()
273 x->n = i; in duk__bi_add()
274 DUK_ASSERT(x->n <= DUK__BI_MAX_PARTS); in duk__bi_add()
281 /* x <- y + z */
295 /* x <- x + y, use t as temp */
302 /* x <- y - z, require x >= y => z >= 0, i.e. y >= z */
312 DUK_ASSERT(y->n >= z->n); in duk__bi_sub()
314 ny = y->n; nz = z->n; in duk__bi_sub()
317 ty = y->v[i]; in duk__bi_sub()
319 tz = z->v[i]; in duk__bi_sub()
323 tmp = (duk_int64_t) ty - (duk_int64_t) tz + tmp; in duk__bi_sub()
324 x->v[i] = (duk_uint32_t) (tmp & 0xffffffffUL); in duk__bi_sub()
325 tmp = tmp >> 32; /* 0 or -1 */ in duk__bi_sub()
329 x->n = i; in duk__bi_sub()
341 DUK_ASSERT(y->n >= z->n); in duk__bi_sub()
343 ny = y->n; nz = z->n; in duk__bi_sub()
346 /* Borrow is detected based on wrapping which relies on exact 32-bit in duk__bi_sub()
349 tmp1 = y->v[i]; in duk__bi_sub()
352 tmp2 -= z->v[i]; in duk__bi_sub()
356 * - If borrow not subtracted: 0x12345678 - 0 - 0xffffffff = 0x12345679 (> 0x12345678) in duk__bi_sub()
357 * - If borrow subtracted: 0x12345678 - 1 - 0xffffffff = 0x12345678 (== 0x12345678) in duk__bi_sub()
360 tmp2--; in duk__bi_sub()
366 x->v[i] = tmp2; in duk__bi_sub()
370 x->n = i; in duk__bi_sub()
377 /* x <- y - z */
391 /* x <- x - y, use t as temp */
397 /* x <- y * z */
404 nx = y->n + z->n; /* max possible */ in duk__bi_mul()
411 x->n = 0; in duk__bi_mul()
415 DUK_MEMZERO((void *) x->v, (size_t) (sizeof(duk_uint32_t) * nx)); in duk__bi_mul()
416 x->n = nx; in duk__bi_mul()
418 nz = z->n; in duk__bi_mul()
419 for (i = 0; i < y->n; i++) { in duk__bi_mul()
423 tmp += (duk_uint64_t) y->v[i] * (duk_uint64_t) z->v[j] + x->v[i+j]; in duk__bi_mul()
424 x->v[i+j] = (duk_uint32_t) (tmp & 0xffffffffUL); in duk__bi_mul()
430 DUK_ASSERT(x->v[i+j] == 0U); in duk__bi_mul()
431 x->v[i+j] = (duk_uint32_t) tmp; in duk__bi_mul()
435 * Multiply + add + carry for 32-bit components using only 16x16->32 in duk__bi_mul()
438 * 1st mult, 32-bit: (A*2^16 + B) in duk__bi_mul()
439 * 2nd mult, 32-bit: (C*2^16 + D) in duk__bi_mul()
440 * 3rd add, 32-bit: E in duk__bi_mul()
441 * 4th add, 32-bit: F in duk__bi_mul()
451 a = y->v[i]; b = a & 0xffffUL; a = a >> 16; in duk__bi_mul()
455 c = z->v[j]; d = c & 0xffffUL; c = c >> 16; in duk__bi_mul()
456 e = x->v[i+j]; in duk__bi_mul()
490 DUK_DDD(DUK_DDDPRINT("ab=%08lx cd=%08lx ef=%08lx -> rs=%08lx %08lx", in duk__bi_mul()
491 (unsigned long) y->v[i], (unsigned long) z->v[j], in duk__bi_mul()
492 (unsigned long) x->v[i+j], (unsigned long) r, in duk__bi_mul()
495 x->v[i+j] = s; in duk__bi_mul()
501 DUK_ASSERT(x->v[i+j] == 0U); in duk__bi_mul()
502 x->v[i+j] = (duk_uint32_t) f; in duk__bi_mul()
511 /* x <- y * z */
524 /* x <- x * y, use t as temp */
530 /* x <- x * y, use t as temp */
538 return (x->n == 0) || ((x->v[0] & 0x01) == 0); in duk__bi_is_even()
543 return (x->n == 0); /* this is the case for normalized numbers */ in duk__bi_is_zero()
555 (x->n == 2) && (x->v[0] == 0U) && (x->v[1] == (1U << (52-32))); in duk__bi_is_2to52()
558 /* x <- (1<<y) */
565 DUK_MEMZERO((void *) x->v, sizeof(duk_uint32_t) * n); in duk__bi_twoexp()
566 x->n = n; in duk__bi_twoexp()
567 x->v[n - 1] = (((duk_uint32_t) 1) << r); in duk__bi_twoexp()
570 /* x <- b^y; use t1 and t2 as temps */
608 * A Dragon4 number-to-string variant, based on:
610 * Guy L. Steele Jr., Jon L. White: "How to Print Floating-Point Numbers
613 * Robert G. Burger, R. Kent Dybvig: "Printing Floating-Point Numbers
616 * The current algorithm is based on Figure 1 of the Burger-Dybvig paper,
618 * (these would increase code footprint considerably). Fixed-format output
620 * extra digit and round-with-carry.
625 * See doc/number-conversion.rst for limitations.
632 #define DUK__MAX_FORMATTED_LENGTH 1040 /* (-Number.MAX_VALUE).toString(2).length == 1025, + …
646 duk_small_int_t is_s2n; /* if 1, doing a string-to-number; else doing a number-to-string */
648 duk_small_int_t req_digits; /* requested number of output digits; 0 = free-format */
656 duk_small_int_t unequal_gaps; /* m+ != m- (very rarely) */
658 /* Buffer used for generated digits, values are in the range [0,B-1]. */
668 DUK_ASSERT((preinc_idx) - 1 >= 0); \
669 DUK_ASSERT((preinc_idx) - 1 < DUK__MAX_OUTPUT_DIGITS); \
670 ((nc_ctx)->digits[(preinc_idx) - 1]) = (duk_uint8_t) (x); \
681 /* A 32-bit unsigned integer formats to at most 32 digits (the in duk__dragon4_format_uint32()
689 dig = x - t * radix; in duk__dragon4_format_uint32()
693 *(--p) = DUK__DIGITCHAR(dig); in duk__dragon4_format_uint32()
699 len = (duk_size_t) ((buf + 32) - p); in duk__dragon4_format_uint32()
710 /* Assume IEEE round-to-even, so that shorter encoding can be used in duk__dragon4_prepare()
711 * when round-to-even would produce correct result. By removing in duk__dragon4_prepare()
715 if (duk__bi_is_even(&nc_ctx->f)) { in duk__dragon4_prepare()
717 nc_ctx->low_ok = 1; in duk__dragon4_prepare()
718 nc_ctx->high_ok = 1; in duk__dragon4_prepare()
721 nc_ctx->low_ok = 0; in duk__dragon4_prepare()
722 nc_ctx->high_ok = 0; in duk__dragon4_prepare()
725 /* Note: not honoring round-to-even should work but now generates incorrect in duk__dragon4_prepare()
731 nc_ctx->low_ok = 0; in duk__dragon4_prepare()
732 nc_ctx->high_ok = 0; in duk__dragon4_prepare()
735 /* For string-to-number, pretend we never have the lowest mantissa as there in duk__dragon4_prepare()
739 if (nc_ctx->is_s2n) { in duk__dragon4_prepare()
742 lowest_mantissa = duk__bi_is_2to52(&nc_ctx->f); in duk__dragon4_prepare()
745 nc_ctx->unequal_gaps = 0; in duk__dragon4_prepare()
746 if (nc_ctx->e >= 0) { in duk__dragon4_prepare()
747 /* exponent non-negative (and thus not minimum exponent) */ in duk__dragon4_prepare()
750 /* (>= e 0) AND (= f (expt b (- p 1))) in duk__dragon4_prepare()
752 * be <- (expt b e) == b^e in duk__dragon4_prepare()
753 * be1 <- (* be b) == (expt b (+ e 1)) == b^(e+1) in duk__dragon4_prepare()
754 * r <- (* f be1 2) == 2 * f * b^(e+1) [if b==2 -> f * b^(e+2)] in duk__dragon4_prepare()
755 * s <- (* b 2) [if b==2 -> 4] in duk__dragon4_prepare()
756 * m+ <- be1 == b^(e+1) in duk__dragon4_prepare()
757 * m- <- be == b^e in duk__dragon4_prepare()
758 * k <- 0 in duk__dragon4_prepare()
759 * B <- B in duk__dragon4_prepare()
760 * low_ok <- round in duk__dragon4_prepare()
761 * high_ok <- round in duk__dragon4_prepare()
764 DUK_DDD(DUK_DDDPRINT("non-negative exponent (not smallest exponent); " in duk__dragon4_prepare()
765 "lowest mantissa value for this exponent -> " in duk__dragon4_prepare()
768 duk__bi_exp_small(&nc_ctx->mm, nc_ctx->b, nc_ctx->e, &nc_ctx->t1, &nc_ctx->t2); /* mm <- b^e */ in duk__dragon4_prepare()
769 duk__bi_mul_small(&nc_ctx->mp, &nc_ctx->mm, nc_ctx->b); /* mp <- b^(e+1) */ in duk__dragon4_prepare()
770 duk__bi_mul_small(&nc_ctx->t1, &nc_ctx->f, 2); in duk__dragon4_prepare()
771 duk__bi_mul(&nc_ctx->r, &nc_ctx->t1, &nc_ctx->mp); /* r <- (2 * f) * b^(e+1) */ in duk__dragon4_prepare()
772 duk__bi_set_small(&nc_ctx->s, nc_ctx->b * 2); /* s <- 2 * b */ in duk__dragon4_prepare()
773 nc_ctx->unequal_gaps = 1; in duk__dragon4_prepare()
775 /* (>= e 0) AND (not (= f (expt b (- p 1)))) in duk__dragon4_prepare()
777 * be <- (expt b e) == b^e in duk__dragon4_prepare()
778 * r <- (* f be 2) == 2 * f * b^e [if b==2 -> f * b^(e+1)] in duk__dragon4_prepare()
779 * s <- 2 in duk__dragon4_prepare()
780 * m+ <- be == b^e in duk__dragon4_prepare()
781 * m- <- be == b^e in duk__dragon4_prepare()
782 * k <- 0 in duk__dragon4_prepare()
783 * B <- B in duk__dragon4_prepare()
784 * low_ok <- round in duk__dragon4_prepare()
785 * high_ok <- round in duk__dragon4_prepare()
788 DUK_DDD(DUK_DDDPRINT("non-negative exponent (not smallest exponent); " in duk__dragon4_prepare()
789 "not lowest mantissa for this exponent -> " in duk__dragon4_prepare()
792 duk__bi_exp_small(&nc_ctx->mm, nc_ctx->b, nc_ctx->e, &nc_ctx->t1, &nc_ctx->t2); /* mm <- b^e */ in duk__dragon4_prepare()
793 duk__bi_copy(&nc_ctx->mp, &nc_ctx->mm); /* mp <- b^e */ in duk__dragon4_prepare()
794 duk__bi_mul_small(&nc_ctx->t1, &nc_ctx->f, 2); in duk__dragon4_prepare()
795 duk__bi_mul(&nc_ctx->r, &nc_ctx->t1, &nc_ctx->mp); /* r <- (2 * f) * b^e */ in duk__dragon4_prepare()
796 duk__bi_set_small(&nc_ctx->s, 2); /* s <- 2 */ in duk__dragon4_prepare()
799 /* When doing string-to-number, lowest_mantissa is always 0 so in duk__dragon4_prepare()
802 if (nc_ctx->e > DUK__IEEE_DOUBLE_EXP_MIN /*not minimum exponent*/ && in duk__dragon4_prepare()
804 /* r <- (* f b 2) [if b==2 -> (* f 4)] in duk__dragon4_prepare()
805 * s <- (* (expt b (- 1 e)) 2) == b^(1-e) * 2 [if b==2 -> b^(2-e)] in duk__dragon4_prepare()
806 * m+ <- b == 2 in duk__dragon4_prepare()
807 * m- <- 1 in duk__dragon4_prepare()
808 * k <- 0 in duk__dragon4_prepare()
809 * B <- B in duk__dragon4_prepare()
810 * low_ok <- round in duk__dragon4_prepare()
811 * high_ok <- round in duk__dragon4_prepare()
815 "lowest mantissa for this exponent -> " in duk__dragon4_prepare()
818 duk__bi_mul_small(&nc_ctx->r, &nc_ctx->f, nc_ctx->b * 2); /* r <- (2 * b) * f */ in duk__dragon4_prepare()
819 …duk__bi_exp_small(&nc_ctx->t1, nc_ctx->b, 1 - nc_ctx->e, &nc_ctx->s, &nc_ctx->t2); /* NB: use 's'… in duk__dragon4_prepare()
820 duk__bi_mul_small(&nc_ctx->s, &nc_ctx->t1, 2); /* s <- b^(1-e) * 2 */ in duk__dragon4_prepare()
821 duk__bi_set_small(&nc_ctx->mp, 2); in duk__dragon4_prepare()
822 duk__bi_set_small(&nc_ctx->mm, 1); in duk__dragon4_prepare()
823 nc_ctx->unequal_gaps = 1; in duk__dragon4_prepare()
825 /* r <- (* f 2) in duk__dragon4_prepare()
826 * s <- (* (expt b (- e)) 2) == b^(-e) * 2 [if b==2 -> b^(1-e)] in duk__dragon4_prepare()
827 * m+ <- 1 in duk__dragon4_prepare()
828 * m- <- 1 in duk__dragon4_prepare()
829 * k <- 0 in duk__dragon4_prepare()
830 * B <- B in duk__dragon4_prepare()
831 * low_ok <- round in duk__dragon4_prepare()
832 * high_ok <- round in duk__dragon4_prepare()
836 "lowest mantissa for this exponent -> " in duk__dragon4_prepare()
839 duk__bi_mul_small(&nc_ctx->r, &nc_ctx->f, 2); /* r <- 2 * f */ in duk__dragon4_prepare()
840 …duk__bi_exp_small(&nc_ctx->t1, nc_ctx->b, -nc_ctx->e, &nc_ctx->s, &nc_ctx->t2); /* NB: use 's' as… in duk__dragon4_prepare()
841 duk__bi_mul_small(&nc_ctx->s, &nc_ctx->t1, 2); /* s <- b^(-e) * 2 */ in duk__dragon4_prepare()
842 duk__bi_set_small(&nc_ctx->mp, 1); in duk__dragon4_prepare()
843 duk__bi_set_small(&nc_ctx->mm, 1); in duk__dragon4_prepare()
858 * value, after which 's' is updated separately (see the Burger-Dybvig in duk__dragon4_scale()
861 * The case where m+ == m- (almost always) is optimized for, because in duk__dragon4_scale()
868 * using a lookup table or using some bit-representation based exp in duk__dragon4_scale()
874 (long) nc_ctx->B, (long) nc_ctx->low_ok, (long) nc_ctx->high_ok)); in duk__dragon4_scale()
875 DUK__BI_PRINT("r(init)", &nc_ctx->r); in duk__dragon4_scale()
876 DUK__BI_PRINT("s(init)", &nc_ctx->s); in duk__dragon4_scale()
877 DUK__BI_PRINT("mp(init)", &nc_ctx->mp); in duk__dragon4_scale()
878 DUK__BI_PRINT("mm(init)", &nc_ctx->mm); in duk__dragon4_scale()
882 DUK__BI_PRINT("r", &nc_ctx->r); in duk__dragon4_scale()
883 DUK__BI_PRINT("s", &nc_ctx->s); in duk__dragon4_scale()
884 DUK__BI_PRINT("m+", &nc_ctx->mp); in duk__dragon4_scale()
885 DUK__BI_PRINT("m-", &nc_ctx->mm); in duk__dragon4_scale()
887 duk__bi_add(&nc_ctx->t1, &nc_ctx->r, &nc_ctx->mp); /* t1 = (+ r m+) */ in duk__dragon4_scale()
888 if (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) >= (nc_ctx->high_ok ? 0 : 1)) { in duk__dragon4_scale()
890 /* r <- r in duk__dragon4_scale()
891 * s <- (* s B) in duk__dragon4_scale()
892 * m+ <- m+ in duk__dragon4_scale()
893 * m- <- m- in duk__dragon4_scale()
894 * k <- (+ k 1) in duk__dragon4_scale()
897 duk__bi_mul_small_copy(&nc_ctx->s, nc_ctx->B, &nc_ctx->t1); in duk__dragon4_scale()
904 /* k > 0 -> k was too low, and cannot be too high */ in duk__dragon4_scale()
911 DUK__BI_PRINT("r", &nc_ctx->r); in duk__dragon4_scale()
912 DUK__BI_PRINT("s", &nc_ctx->s); in duk__dragon4_scale()
913 DUK__BI_PRINT("m+", &nc_ctx->mp); in duk__dragon4_scale()
914 DUK__BI_PRINT("m-", &nc_ctx->mm); in duk__dragon4_scale()
916 duk__bi_add(&nc_ctx->t1, &nc_ctx->r, &nc_ctx->mp); /* t1 = (+ r m+) */ in duk__dragon4_scale()
917 duk__bi_mul_small(&nc_ctx->t2, &nc_ctx->t1, nc_ctx->B); /* t2 = (* (+ r m+) B) */ in duk__dragon4_scale()
918 if (duk__bi_compare(&nc_ctx->t2, &nc_ctx->s) <= (nc_ctx->high_ok ? -1 : 0)) { in duk__dragon4_scale()
920 /* r <- (* r B) in duk__dragon4_scale()
921 * s <- s in duk__dragon4_scale()
922 * m+ <- (* m+ B) in duk__dragon4_scale()
923 * m- <- (* m- B) in duk__dragon4_scale()
924 * k <- (- k 1) in duk__dragon4_scale()
926 duk__bi_mul_small_copy(&nc_ctx->r, nc_ctx->B, &nc_ctx->t1); in duk__dragon4_scale()
927 duk__bi_mul_small_copy(&nc_ctx->mp, nc_ctx->B, &nc_ctx->t1); in duk__dragon4_scale()
928 if (nc_ctx->unequal_gaps) { in duk__dragon4_scale()
929 DUK_DDD(DUK_DDDPRINT("m+ != m- -> need to update m- too")); in duk__dragon4_scale()
930 duk__bi_mul_small_copy(&nc_ctx->mm, nc_ctx->B, &nc_ctx->t1); in duk__dragon4_scale()
932 k--; in duk__dragon4_scale()
940 if (!nc_ctx->unequal_gaps) { in duk__dragon4_scale()
941 DUK_DDD(DUK_DDDPRINT("equal gaps, copy m- from m+")); in duk__dragon4_scale()
942 duk__bi_copy(&nc_ctx->mm, &nc_ctx->mp); /* mm <- mp */ in duk__dragon4_scale()
944 nc_ctx->k = k; in duk__dragon4_scale()
947 DUK__BI_PRINT("r(final)", &nc_ctx->r); in duk__dragon4_scale()
948 DUK__BI_PRINT("s(final)", &nc_ctx->s); in duk__dragon4_scale()
949 DUK__BI_PRINT("mp(final)", &nc_ctx->mp); in duk__dragon4_scale()
950 DUK__BI_PRINT("mm(final)", &nc_ctx->mm); in duk__dragon4_scale()
970 * 3. Fixed format output, with a specific absolute cut-off in duk__dragon4_generate()
973 * the digit is below the cut-off point already. in duk__dragon4_generate()
978 (long) count, (long) nc_ctx->k, (long) nc_ctx->B, in duk__dragon4_generate()
979 (long) nc_ctx->low_ok, (long) nc_ctx->high_ok)); in duk__dragon4_generate()
980 DUK__BI_PRINT("r", &nc_ctx->r); in duk__dragon4_generate()
981 DUK__BI_PRINT("s", &nc_ctx->s); in duk__dragon4_generate()
982 DUK__BI_PRINT("m+", &nc_ctx->mp); in duk__dragon4_generate()
983 DUK__BI_PRINT("m-", &nc_ctx->mm); in duk__dragon4_generate()
985 /* (quotient-remainder (* r B) s) using a dummy subtraction loop */ in duk__dragon4_generate()
986 duk__bi_mul_small(&nc_ctx->t1, &nc_ctx->r, nc_ctx->B); /* t1 <- (* r B) */ in duk__dragon4_generate()
989 if (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) < 0) { in duk__dragon4_generate()
992 duk__bi_sub_copy(&nc_ctx->t1, &nc_ctx->s, &nc_ctx->t2); /* t1 <- t1 - s */ in duk__dragon4_generate()
995 duk__bi_copy(&nc_ctx->r, &nc_ctx->t1); /* r <- (remainder (* r B) s) */ in duk__dragon4_generate()
996 /* d <- (quotient (* r B) s) (in range 0...B-1) */ in duk__dragon4_generate()
997 DUK_DDD(DUK_DDDPRINT("-> d(quot)=%ld", (long) d)); in duk__dragon4_generate()
998 DUK__BI_PRINT("r(rem)", &nc_ctx->r); in duk__dragon4_generate()
1000 duk__bi_mul_small_copy(&nc_ctx->mp, nc_ctx->B, &nc_ctx->t2); /* m+ <- (* m+ B) */ in duk__dragon4_generate()
1001 duk__bi_mul_small_copy(&nc_ctx->mm, nc_ctx->B, &nc_ctx->t2); /* m- <- (* m- B) */ in duk__dragon4_generate()
1002 DUK__BI_PRINT("mp(upd)", &nc_ctx->mp); in duk__dragon4_generate()
1003 DUK__BI_PRINT("mm(upd)", &nc_ctx->mm); in duk__dragon4_generate()
1007 * the current shortcut for fixed-format output is to generate a few in duk__dragon4_generate()
1011 if (nc_ctx->is_fixed == 0) { in duk__dragon4_generate()
1012 /* free-form */ in duk__dragon4_generate()
1013 tc1 = (duk__bi_compare(&nc_ctx->r, &nc_ctx->mm) <= (nc_ctx->low_ok ? 0 : -1)); in duk__dragon4_generate()
1015 duk__bi_add(&nc_ctx->t1, &nc_ctx->r, &nc_ctx->mp); /* t1 <- (+ r m+) */ in duk__dragon4_generate()
1016 tc2 = (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) >= (nc_ctx->high_ok ? 0 : 1)); in duk__dragon4_generate()
1020 /* fixed-format */ in duk__dragon4_generate()
1033 duk__bi_mul_small(&nc_ctx->t1, &nc_ctx->r, 2); in duk__dragon4_generate()
1034 if (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) < 0) { /* (< (* r 2) s) */ in duk__dragon4_generate()
1035 DUK_DDD(DUK_DDDPRINT("tc1=true, tc2=true, 2r > s: output d --> %ld (k=%ld)", in duk__dragon4_generate()
1036 (long) d, (long) nc_ctx->k)); in duk__dragon4_generate()
1039 DUK_DDD(DUK_DDDPRINT("tc1=true, tc2=true, 2r <= s: output d+1 --> %ld (k=%ld)", in duk__dragon4_generate()
1040 (long) (d + 1), (long) nc_ctx->k)); in duk__dragon4_generate()
1046 DUK_DDD(DUK_DDDPRINT("tc1=true, tc2=false: output d --> %ld (k=%ld)", in duk__dragon4_generate()
1047 (long) d, (long) nc_ctx->k)); in duk__dragon4_generate()
1054 DUK_DDD(DUK_DDDPRINT("tc1=false, tc2=true: output d+1 --> %ld (k=%ld)", in duk__dragon4_generate()
1055 (long) (d + 1), (long) nc_ctx->k)); in duk__dragon4_generate()
1060 DUK_DDD(DUK_DDDPRINT("tc1=false, tc2=false: output d --> %ld (k=%ld)", in duk__dragon4_generate()
1061 (long) d, (long) nc_ctx->k)); in duk__dragon4_generate()
1064 /* r <- r (updated above: r <- (remainder (* r B) s) in duk__dragon4_generate()
1065 * s <- s in duk__dragon4_generate()
1066 * m+ <- m+ (updated above: m+ <- (* m+ B) in duk__dragon4_generate()
1067 * m- <- m- (updated above: m- <- (* m- B) in duk__dragon4_generate()
1071 /* fall through and continue for-loop */ in duk__dragon4_generate()
1075 /* fixed-format termination conditions */ in duk__dragon4_generate()
1076 if (nc_ctx->is_fixed) { in duk__dragon4_generate()
1077 if (nc_ctx->abs_pos) { in duk__dragon4_generate()
1078 int pos = nc_ctx->k - count + 1; /* count is already incremented, take into account */ in duk__dragon4_generate()
1080 (long) pos, (long) nc_ctx->k, (long) count, (long) nc_ctx->req_digits)); in duk__dragon4_generate()
1081 if (pos <= nc_ctx->req_digits) { in duk__dragon4_generate()
1087 (long) nc_ctx->k, (long) count, (long) nc_ctx->req_digits)); in duk__dragon4_generate()
1088 if (count >= nc_ctx->req_digits) { in duk__dragon4_generate()
1096 nc_ctx->count = count; in duk__dragon4_generate()
1105 for (i = 0; i < nc_ctx->count; i++) { in duk__dragon4_generate()
1106 t = nc_ctx->digits[i]; in duk__dragon4_generate()
1113 DUK_DDD(DUK_DDDPRINT("-> generated digits; k=%ld, digits='%s'", in duk__dragon4_generate()
1114 (long) nc_ctx->k, (const char *) buf)); in duk__dragon4_generate()
1119 /* Round up digits to a given position. If position is out-of-bounds,
1124 * Note that nc_ctx->count is NOT updated based on the rounding position
1141 if (round_idx >= nc_ctx->count) { in duk__dragon4_fixed_format_round()
1142 DUK_DDD(DUK_DDDPRINT("round_idx out of bounds (%ld >= %ld (count)) -> no rounding", in duk__dragon4_fixed_format_round()
1143 (long) round_idx, (long) nc_ctx->count)); in duk__dragon4_fixed_format_round()
1146 DUK_DDD(DUK_DDDPRINT("round_idx out of bounds (%ld < 0) -> no rounding", in duk__dragon4_fixed_format_round()
1152 * Round-up limit. in duk__dragon4_fixed_format_round()
1154 * For even values, divides evenly, e.g. 10 -> roundup_limit=5. in duk__dragon4_fixed_format_round()
1156 * For odd values, rounds up, e.g. 3 -> roundup_limit=2. in duk__dragon4_fixed_format_round()
1157 * If radix is 3, 0/3 -> down, 1/3 -> down, 2/3 -> up. in duk__dragon4_fixed_format_round()
1159 roundup_limit = (duk_uint8_t) ((nc_ctx->B + 1) / 2); in duk__dragon4_fixed_format_round()
1161 p = &nc_ctx->digits[round_idx]; in duk__dragon4_fixed_format_round()
1163 DUK_DDD(DUK_DDDPRINT("fixed-format rounding carry required")); in duk__dragon4_fixed_format_round()
1167 if (p == &nc_ctx->digits[0]) { in duk__dragon4_fixed_format_round()
1168 DUK_DDD(DUK_DDDPRINT("carry propagated to first digit -> special case handling")); in duk__dragon4_fixed_format_round()
1169 DUK_MEMMOVE((void *) (&nc_ctx->digits[1]), in duk__dragon4_fixed_format_round()
1170 (const void *) (&nc_ctx->digits[0]), in duk__dragon4_fixed_format_round()
1171 (size_t) (sizeof(char) * nc_ctx->count)); in duk__dragon4_fixed_format_round()
1172 nc_ctx->digits[0] = 1; /* don't increase 'count' */ in duk__dragon4_fixed_format_round()
1173 nc_ctx->k++; /* position of highest digit changed */ in duk__dragon4_fixed_format_round()
1174 nc_ctx->count++; /* number of digits changed */ in duk__dragon4_fixed_format_round()
1179 DUK_DDD(DUK_DDDPRINT("fixed-format rounding carry: B=%ld, roundup_limit=%ld, p=%p, digits=%p", in duk__dragon4_fixed_format_round()
1180 … (long) nc_ctx->B, (long) roundup_limit, (void *) p, (void *) nc_ctx->digits)); in duk__dragon4_fixed_format_round()
1181 p--; in duk__dragon4_fixed_format_round()
1184 if (++t < nc_ctx->B) { in duk__dragon4_fixed_format_round()
1214 * semantics without attempting to be generic. nc_ctx->digits contains in duk__dragon4_convert_and_push()
1215 * nc_ctx->count digits (>= 1), with the topmost digit's 'position' in duk__dragon4_convert_and_push()
1216 * indicated by nc_ctx->k as follows: in duk__dragon4_convert_and_push()
1218 * digits="123" count=3 k=0 --> 0.123 in duk__dragon4_convert_and_push()
1219 * digits="123" count=3 k=1 --> 1.23 in duk__dragon4_convert_and_push()
1220 * digits="123" count=3 k=5 --> 12300 in duk__dragon4_convert_and_push()
1221 * digits="123" count=3 k=-1 --> 0.0123 in duk__dragon4_convert_and_push()
1224 * in Burger-Dybvig paper and Ecmascript specification (quite confusingly in duk__dragon4_convert_and_push()
1229 * (e.g. when to use exponent notation) for non-base-10 numbers. in duk__dragon4_convert_and_push()
1237 DUK_ASSERT(nc_ctx->count >= 1); in duk__dragon4_convert_and_push()
1239 k = nc_ctx->k; in duk__dragon4_convert_and_push()
1240 buf = (duk_uint8_t *) &nc_ctx->f; /* XXX: union would be more correct */ in duk__dragon4_convert_and_push()
1244 * fake k such that one leading digit is generated (e.g. digits=123 -> "1.23"). in duk__dragon4_convert_and_push()
1251 if (!nc_ctx->abs_pos /* toFixed() */) { in duk__dragon4_convert_and_push()
1254 (k - digits >= 1)) || /* (e.g. k=3, digits=2 -> "12X") */ in duk__dragon4_convert_and_push()
1255 ((k > 21 || k <= -6) && (radix == 10))) { /* toString() conditions */ in duk__dragon4_convert_and_push()
1256 DUK_DDD(DUK_DDDPRINT("use exponential notation: k=%ld -> expt=%ld", in duk__dragon4_convert_and_push()
1257 (long) k, (long) (k - 1))); in duk__dragon4_convert_and_push()
1258 expt = k - 1; /* e.g. 12.3 -> digits="123" k=2 -> 1.23e1 */ in duk__dragon4_convert_and_push()
1264 *q++ = '-'; in duk__dragon4_convert_and_push()
1269 if (nc_ctx->is_fixed) { in duk__dragon4_convert_and_push()
1270 if (nc_ctx->abs_pos) { in duk__dragon4_convert_and_push()
1272 pos_end = -digits; in duk__dragon4_convert_and_push()
1274 pos_end = k - digits; in duk__dragon4_convert_and_push()
1277 pos_end = k - nc_ctx->count; in duk__dragon4_convert_and_push()
1285 (long) expt, (long) k, (long) nc_ctx->count, (long) pos, (long) pos_end, in duk__dragon4_convert_and_push()
1286 (long) nc_ctx->is_fixed, (long) digits, (long) nc_ctx->abs_pos)); in duk__dragon4_convert_and_push()
1297 } else if (pos <= k - nc_ctx->count) { in duk__dragon4_convert_and_push()
1300 dig = nc_ctx->digits[k - pos]; in duk__dragon4_convert_and_push()
1301 DUK_ASSERT(dig >= 0 && dig < nc_ctx->B); in duk__dragon4_convert_and_push()
1305 pos--; in duk__dragon4_convert_and_push()
1312 * Exponent notation for non-base-10 numbers isn't specified in Ecmascript in duk__dragon4_convert_and_push()
1313 * specification, as it never explicitly turns up: non-decimal numbers can in duk__dragon4_convert_and_push()
1332 expt_sign = '-'; in duk__dragon4_convert_and_push()
1333 expt = -expt; in duk__dragon4_convert_and_push()
1340 duk_push_lstring(ctx, (const char *) buf, (size_t) (q - buf)); in duk__dragon4_convert_and_push()
1360 * ieee value = 1.ffff... * 2^(e - 1023) (normal) in duk__dragon4_double_to_ctx()
1361 * = 0.ffff... * 2^(-1022) (denormal) in duk__dragon4_double_to_ctx()
1368 nc_ctx->f.n = 2; in duk__dragon4_double_to_ctx()
1371 nc_ctx->f.v[0] = tmp; in duk__dragon4_double_to_ctx()
1373 nc_ctx->f.v[1] = tmp & 0x000fffffUL; in duk__dragon4_double_to_ctx()
1378 expt = DUK__IEEE_DOUBLE_EXP_MIN - 52; in duk__dragon4_double_to_ctx()
1379 duk__bi_normalize(&nc_ctx->f); in duk__dragon4_double_to_ctx()
1381 /* normal: implicit leading 1-bit */ in duk__dragon4_double_to_ctx()
1382 nc_ctx->f.v[1] |= 0x00100000UL; in duk__dragon4_double_to_ctx()
1383 expt = expt - DUK__IEEE_DOUBLE_EXP_BIAS - 52; in duk__dragon4_double_to_ctx()
1384 DUK_ASSERT(duk__bi_is_valid(&nc_ctx->f)); /* true, because v[1] has at least one bit set */ in duk__dragon4_double_to_ctx()
1387 DUK_ASSERT(duk__bi_is_valid(&nc_ctx->f)); in duk__dragon4_double_to_ctx()
1389 nc_ctx->e = expt; in duk__dragon4_double_to_ctx()
1402 DUK_ASSERT(nc_ctx->count == 53 + 1); in duk__dragon4_ctx_to_double()
1405 * rounding. See: test-bug-numconv-mantissa-assert.js. in duk__dragon4_ctx_to_double()
1407 DUK_ASSERT_DISABLE(nc_ctx->digits[0] == 1); /* zero handled by caller */ in duk__dragon4_ctx_to_double()
1410 * and low parts, but at least gcc-4.4.5 fails to deduce this correctly in duk__dragon4_ctx_to_double()
1426 * <--------52------->| in duk__dragon4_ctx_to_double()
1433 * <--52 or less--->| in duk__dragon4_ctx_to_double()
1444 * Note: the Dragon4 'k' is off-by-one with respect to the IEEE in duk__dragon4_ctx_to_double()
1447 * the corresponding IEEE exponent would be -1. in duk__dragon4_ctx_to_double()
1454 expt = nc_ctx->k - 1; /* IEEE exp without bias */ in duk__dragon4_ctx_to_double()
1457 bitstart = -255; /* needed for inf: causes mantissa to become zero, in duk__dragon4_ctx_to_double()
1461 } else if (expt >= -1022) { in duk__dragon4_ctx_to_double()
1468 bitstart = 1023 + expt; /* expt==-1023 -> bitstart=0 (leading 1); in duk__dragon4_ctx_to_double()
1469 * expt==-1024 -> bitstart=-1 (one left of leading 1), etc in duk__dragon4_ctx_to_double()
1480 /* Corner case: see test-numconv-parse-mant-carry.js. We could in duk__dragon4_ctx_to_double()
1496 bitidx = bitstart + 52 - 1 - i; in duk__dragon4_ctx_to_double()
1497 if (bitidx >= nc_ctx->count) { in duk__dragon4_ctx_to_double()
1502 v = nc_ctx->digits[bitidx]; in duk__dragon4_ctx_to_double()
1535 * Exposed number-to-string API
1549 x = (duk_double_t) duk_require_number(ctx, -1); in duk_numconv_stringify()
1558 x = -x; in duk_numconv_stringify()
1564 /* NaN sign bit is platform specific with unpacked, un-normalized NaNs */ in duk_numconv_stringify()
1572 /* -Infinity */ in duk_numconv_stringify()
1587 * Handle integers in 32-bit range (that is, [-(2**32-1),2**32-1]) in duk_numconv_stringify()
1601 duk_uint8_t *buf = (duk_uint8_t *) (&nc_ctx->f); in duk_numconv_stringify()
1607 *p++ = (duk_uint8_t) '-'; in duk_numconv_stringify()
1610 duk_push_lstring(ctx, (const char *) buf, (duk_size_t) (p - buf)); in duk_numconv_stringify()
1618 * normal finite values have an implicit leading 1-bit. The in duk_numconv_stringify()
1622 * been requested (e.g. forced exponential format: 0 -> "0e+0"). in duk_numconv_stringify()
1626 * is 1-2 kilobytes and nothing should rely on it being zeroed. in duk_numconv_stringify()
1632 nc_ctx->is_s2n = 0; in duk_numconv_stringify()
1633 nc_ctx->b = 2; in duk_numconv_stringify()
1634 nc_ctx->B = radix; in duk_numconv_stringify()
1635 nc_ctx->abs_pos = 0; in duk_numconv_stringify()
1637 nc_ctx->is_fixed = 1; in duk_numconv_stringify()
1639 /* absolute req_digits; e.g. digits = 1 -> last digit is 0, in duk_numconv_stringify()
1642 nc_ctx->abs_pos = 1; in duk_numconv_stringify()
1643 nc_ctx->req_digits = (-digits + 1) - 1; in duk_numconv_stringify()
1645 nc_ctx->req_digits = digits + 1; in duk_numconv_stringify()
1648 nc_ctx->is_fixed = 0; in duk_numconv_stringify()
1649 nc_ctx->req_digits = 0; in duk_numconv_stringify()
1658 if (nc_ctx->is_fixed) { in duk_numconv_stringify()
1659 if (nc_ctx->abs_pos) { in duk_numconv_stringify()
1669 DUK_MEMZERO((void *) nc_ctx->digits, count); in duk_numconv_stringify()
1670 nc_ctx->count = count; in duk_numconv_stringify()
1671 nc_ctx->k = 1; /* 0.000... */ in duk_numconv_stringify()
1676 duk__dragon4_double_to_ctx(nc_ctx, x); /* -> sets 'f' and 'e' */ in duk_numconv_stringify()
1677 DUK__BI_PRINT("f", &nc_ctx->f); in duk_numconv_stringify()
1678 DUK_DDD(DUK_DDDPRINT("e=%ld", (long) nc_ctx->e)); in duk_numconv_stringify()
1687 DUK__BI_PRINT("r", &nc_ctx->r); in duk_numconv_stringify()
1688 DUK__BI_PRINT("s", &nc_ctx->s); in duk_numconv_stringify()
1689 DUK__BI_PRINT("mp", &nc_ctx->mp); in duk_numconv_stringify()
1690 DUK__BI_PRINT("mm", &nc_ctx->mm); in duk_numconv_stringify()
1694 DUK_DDD(DUK_DDDPRINT("after scale; k=%ld", (long) nc_ctx->k)); in duk_numconv_stringify()
1695 DUK__BI_PRINT("r", &nc_ctx->r); in duk_numconv_stringify()
1696 DUK__BI_PRINT("s", &nc_ctx->s); in duk_numconv_stringify()
1697 DUK__BI_PRINT("mp", &nc_ctx->mp); in duk_numconv_stringify()
1698 DUK__BI_PRINT("mm", &nc_ctx->mm); in duk_numconv_stringify()
1709 /* Perform fixed-format rounding. */ in duk_numconv_stringify()
1712 /* 'roundpos' is relative to nc_ctx->k and increases to the right in duk_numconv_stringify()
1715 roundpos = -digits; /* absolute position for digit considered for rounding */ in duk_numconv_stringify()
1716 roundpos = nc_ctx->k - roundpos; in duk_numconv_stringify()
1721 (long) nc_ctx->k, (long) nc_ctx->count, (long) digits, (long) roundpos)); in duk_numconv_stringify()
1727 * convert-and-push function. in duk_numconv_stringify()
1735 * Exposed string-to-number API
1783 (duk_tval *) duk_get_tval(ctx, -1), in duk_numconv_parse()
1787 DUK_ASSERT(radix - 2 < (duk_small_int_t) sizeof(duk__str2num_digits_for_radix)); in duk_numconv_parse()
1811 duk_trim(ctx, -1); in duk_numconv_parse()
1813 h_str = duk_require_hstring(ctx, -1); in duk_numconv_parse()
1825 } else if (ch == (duk_small_int_t) '-') { in duk_numconv_parse()
1837 * 'Infinity' is a valid integer literal in e.g. base-36: in duk_numconv_parse()
1892 * For decimal numbers, this means generating a 20-digit significand, in duk_numconv_parse()
1896 * to round the 20th digit upwards). For non-decimal numbers, the in duk_numconv_parse()
1904 * .+-..---[ dig_prec ]----. in duk_numconv_parse()
1908 * `--+--' `------[ dig_frac ]-------' `-+--' in duk_numconv_parse()
1912 * dig_frac and dig_expt are -1 if not present in duk_numconv_parse()
1927 duk__bi_set_small(&nc_ctx->f, 0); in duk_numconv_parse()
1931 dig_frac = -1; in duk_numconv_parse()
1932 dig_expt = -1; in duk_numconv_parse()
1944 DUK__BI_PRINT("f", &nc_ctx->f); in duk_numconv_parse()
1948 dig = (int) ch - '0' + 0; in duk_numconv_parse()
1966 * post-check because the state ('f' and expt) would be incorrect. in duk_numconv_parse()
1995 /* Exponent without a sign or with a +/- sign is accepted in duk_numconv_parse()
1999 if (ch == (duk_small_int_t) '-') { in duk_numconv_parse()
2008 dig = (duk_small_int_t) (ch - (duk_small_int_t) 'a' + 0x0a); in duk_numconv_parse()
2010 dig = (duk_small_int_t) (ch - (duk_small_int_t) 'A' + 0x0a); in duk_numconv_parse()
2029 if (dig_prec < duk__str2num_digits_for_radix[radix - 2]) { in duk_numconv_parse()
2032 duk_small_int_t f_zero = duk__bi_is_zero(&nc_ctx->f); in duk_numconv_parse()
2041 /* XXX: join these ops (multiply-accumulate), but only if in duk_numconv_parse()
2044 duk__bi_mul_small(&nc_ctx->t1, &nc_ctx->f, radix); in duk_numconv_parse()
2045 duk__bi_add_small(&nc_ctx->f, &nc_ctx->t1, dig); in duk_numconv_parse()
2049 /* Ignore digits beyond a radix-specific limit, but note them in duk_numconv_parse()
2057 expt_adj--; in duk_numconv_parse()
2135 expt = -expt; in duk_numconv_parse()
2137 DUK_DDD(DUK_DDDPRINT("expt=%ld, expt_adj=%ld, net exponent -> %ld", in duk_numconv_parse()
2143 if (nc_ctx->f.n <= 1 && /* 32-bit value */ in duk_numconv_parse()
2152 if (nc_ctx->f.n == 1) { in duk_numconv_parse()
2153 res = (double) nc_ctx->f.v[0]; in duk_numconv_parse()
2162 while (dig_prec < duk__str2num_digits_for_radix[radix - 2]) { in duk_numconv_parse()
2167 duk__bi_mul_small_copy(&nc_ctx->f, radix, &nc_ctx->t1); in duk_numconv_parse()
2168 DUK__BI_PRINT("f", &nc_ctx->f); in duk_numconv_parse()
2169 expt--; in duk_numconv_parse()
2177 if (nc_ctx->f.n == 0) { in duk_numconv_parse()
2192 explim = &duk__str2num_exp_limits[radix - 2]; in duk_numconv_parse()
2193 if (expt > explim->upper) { in duk_numconv_parse()
2194 DUK_DDD(DUK_DDDPRINT("exponent too large -> infinite")); in duk_numconv_parse()
2197 } else if (expt < explim->lower) { in duk_numconv_parse()
2198 DUK_DDD(DUK_DDDPRINT("exponent too small -> zero")); in duk_numconv_parse()
2203 nc_ctx->is_s2n = 1; in duk_numconv_parse()
2204 nc_ctx->e = expt; in duk_numconv_parse()
2205 nc_ctx->b = radix; in duk_numconv_parse()
2206 nc_ctx->B = 2; in duk_numconv_parse()
2207 nc_ctx->is_fixed = 1; in duk_numconv_parse()
2208 nc_ctx->abs_pos = 0; in duk_numconv_parse()
2209 nc_ctx->req_digits = 53 + 1; in duk_numconv_parse()
2211 DUK__BI_PRINT("f", &nc_ctx->f); in duk_numconv_parse()
2212 DUK_DDD(DUK_DDDPRINT("e=%ld", (long) nc_ctx->e)); in duk_numconv_parse()
2222 DUK__BI_PRINT("r", &nc_ctx->r); in duk_numconv_parse()
2223 DUK__BI_PRINT("s", &nc_ctx->s); in duk_numconv_parse()
2224 DUK__BI_PRINT("mp", &nc_ctx->mp); in duk_numconv_parse()
2225 DUK__BI_PRINT("mm", &nc_ctx->mm); in duk_numconv_parse()
2229 DUK_DDD(DUK_DDDPRINT("after scale; k=%ld", (long) nc_ctx->k)); in duk_numconv_parse()
2230 DUK__BI_PRINT("r", &nc_ctx->r); in duk_numconv_parse()
2231 DUK__BI_PRINT("s", &nc_ctx->s); in duk_numconv_parse()
2232 DUK__BI_PRINT("mp", &nc_ctx->mp); in duk_numconv_parse()
2233 DUK__BI_PRINT("mm", &nc_ctx->mm); in duk_numconv_parse()
2237 DUK_ASSERT(nc_ctx->count == 53 + 1); in duk_numconv_parse()
2249 res = -res; in duk_numconv_parse()
2253 DUK_DDD(DUK_DDDPRINT("result: %!T", (duk_tval *) duk_get_tval(ctx, -1))); in duk_numconv_parse()