Title: util: fix numericSeparator with negative fractional numbers by Han5991 · Pull Request #59379 · nodejs/node · GitHub
Open Graph Title: util: fix numericSeparator with negative fractional numbers by Han5991 · Pull Request #59379 · nodejs/node
X Title: util: fix numericSeparator with negative fractional numbers by Han5991 · Pull Request #59379 · nodejs/node
Description: util: fix numericSeparator for negative fractional numbers Fixes a bug in util.inspect() where negative fractional numbers between -1 and 0 were incorrectly formatted when using the numericSeparator option. Changes Fix formatNumber function: Use original string representation to preserve negative sign for fractional numbers Update test expectations: Correct scientific notation test to not expect numeric separators Before util.inspect([-0.12, -0.123], { numericSeparator: true }) // Output: '[ 0..12, 0..12_3 ]' ❌ After util.inspect([-0.12, -0.123], { numericSeparator: true }) // Output: '[ -0.12, -0.123 ]' ✅ Root Cause The issue was in the formatNumber function where String(Math.trunc(-0.12)) returns "0" instead of "-0", losing the negative sign. The fix uses the original string representation and properly slices integer and fractional parts while preserving the sign. Testing ✅ Existing regression test now passes ✅ All util.inspect tests pass ✅ No breaking changes to existing functionality Closes #59376
Open Graph Description: util: fix numericSeparator for negative fractional numbers Fixes a bug in util.inspect() where negative fractional numbers between -1 and 0 were incorrectly formatted when using the numericSeparato...
X Description: util: fix numericSeparator for negative fractional numbers Fixes a bug in util.inspect() where negative fractional numbers between -1 and 0 were incorrectly formatted when using the numericSeparato...
Opengraph URL: https://github.com/nodejs/node/pull/59379
X: @github
Domain: redirect.github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:4c9ec30c-c1ae-9751-a648-8f68874a3c4e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DE72:28F93A:9F2744C:D8449B7:6A4BD3D4 |
| html-safe-nonce | 33f488bf426afae00d040b7d6bef71d6551045dcabf928f4589713b858505d23 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTcyOjI4RjkzQTo5RjI3NDRDOkQ4NDQ5Qjc6NkE0QkQzRDQiLCJ2aXNpdG9yX2lkIjoiNjk2OTk3NDkzOTUwMDQwMTYyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3b52541abf5617131634e7ba464f163080956f137d8db26d80276d632f4a04bf |
| hovercard-subject-tag | pull_request:2724778292 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/nodejs/node/pull/59379/files |
| twitter:image | https://avatars.githubusercontent.com/u/73056306?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/73056306?s=400&v=4 |
| og:image:alt | util: fix numericSeparator for negative fractional numbers Fixes a bug in util.inspect() where negative fractional numbers between -1 and 0 were incorrectly formatted when using the numericSeparato... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9df996be9551ac02247d09a2f7f64ece66c35ca28885d346e98fdfda9cdaa37b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b71208a1c9ec7ccf364087569d0551f665dda674 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width