Skip to content

fix: format DS numbers to 16 characters instead of cutting off the exponent - #610

Merged
pieper merged 1 commit into
dcmjs-org:masterfrom
zzoraemon043:fix/ds-number-formatting
Oct 19, 2026
Merged

pieper merged 1 commit into
dcmjs-org:masterfrom
zzoraemon043:fix/ds-number-formatting

Conversation

@zzoraemon043

Copy link
Copy Markdown

Fixes #531

denaturalizeDataset turned numbers into String(n) and then cut DS values to 16 characters, so 3.5163338899999997e-10 became 3.51633388999999 (the exponent was dropped). DS numbers are now formatted with DecimalString.convertToString first, the same formatting writeBytes already uses, which switches to exponential notation to stay within 16 characters. String values are left as they are.

Added a denaturalizeDataset test with the ImageOrientationPatient value from the issue; it fails before the change. jest test/DicomMetaDictionary.test.js test/data-encoding.test.js test/data-options.test.js test/normalizers.test.js passes, prettier and eslint are clean on the changed files.

@netlify

netlify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for dcmjs2 ready!

Name Link
🔨 Latest commit d1bf3e5
🔍 Latest deploy log https://app.netlify.com/projects/dcmjs2/deploys/6ad5b5e252f7765a211a82f7
😎 Deploy Preview https://deploy-preview-610--dcmjs2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pieper
pieper merged commit aee06e4 into dcmjs-org:master Oct 19, 2026
16 checks passed
@pieper

pieper commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix 👍

wayfarer3130 added a commit that referenced this pull request Nov 25, 2026
…e exponent (#654)

* fix(VR): format DS numbers to 16 characters instead of cutting off the exponent

1.0 port of #610 (commit aee06e4), with the round trip test of #624.

denaturalizeDataset in packages/core now formats each number of a DS
array with DecimalString.convertToString before denaturalizeValue, so
3.5163338899999997e-10 is written as 3.5163338900e-10 and not cut to
3.51633388999999.

Both tests go in test/issues/issue531-ds-exponent.test.js (#610 fixes
#531).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(VR): format a single DS number and a Number object to 16 characters

Review items S1 and N1 of the 1.0 port of #610. The 1.x port now also
formats the scalar case: a VM 1 DS attribute, for example
SliceThickness or SliceLocation, is a single number in a 1.x
naturalized dataset, and it went through String() and was cut to 16
characters. A Number object (new Number(...)) is formatted the same way.
One formatDs function serves the scalar and the list form.

master (0.x) has the same scalar gap after #610.

The JSDoc of denaturalizeDataset cites PS3.5 Table 6.2-1. The
bundle-size ceilings move to 1.081 and 1.063 for this change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: record the DS formatting in NAT-U-RT-8 and the release notes

Maintainer decision Q2 of the review of the 1.0 port of #610: NAT-U-RT-8 in docs/specs/naturalized-dataset.md, with the PS3.5 Section 6.2, Table 6.2-1 reference and the test file, and one bullet in beta-1-release-notes.md. No NAT-I rule covers the DS write, so no NAT-I rule changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(bundle-size): raise the dcmjs.es.js ceiling to 1.064 after #652

The rebase onto 1.0-beta adds the declared length clamp of #652 to the DS formatting of this branch: dcmjs.es.js is x1.0632.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Writing a DS number whose String() is longer than 16 characters cuts off the exponent (3.5e-10 is written as 3.516…)

2 participants