| 537 | } |
| 538 | return v; |
| 539 | } |
| 540 | |
| 541 | JSValue JS_NewBigInt64(JSContext* ctx, int64_t v); |
| 542 | JSValue JS_NewBigUint64(JSContext* ctx, uint64_t v); |
| 543 | |
| 544 | static js_force_inline JSValue JS_NewFloat64(JSContext* ctx, double d) { |
| 545 | JSValue v; |
| 546 | int32_t val; |
| 547 | union { |
| 548 | double d; |
| 549 | uint64_t u; |
| 550 | } u, t; |
| 551 | u.d = d; |
| 552 | val = (int32_t)d; |
| 553 | t.d = val; |
| 554 | /* -0 cannot be represented as integer, so we compare the bit |
| 555 | representation */ |
| 556 | if (u.u == t.u) { |
| 557 | v = JS_MKVAL(JS_TAG_INT, val); |
| 558 | } else { |
| 559 | v = __JS_NewFloat64(ctx, d); |
| 560 | } |
no test coverage detected