Remove toPlainString, unify string representation under toString#3
Merged
Conversation
Preserve trailing zeros in Deci string representation to maintain scale fidelity for financial use cases (e.g. "1.50" stays "1.50"). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
DecimalJs.toString() can use scientific notation for extreme values. The plan now replaces toString() with toFixed()-based implementation on both JS and wasmJs platforms, not just removing toPlainString(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… to describe plain-string semantics Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… remove toPlainString() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…g(), remove toPlainString() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…PlainString() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e toPlainString() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…es plain-string formatting Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tion Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove consecutive blank line in Deci.kt expect declaration - Remove redundant toString() calls in string templates (DeciFormatting, DeciValidation) - Update division test to expect full 20-digit scale (consequence of preserving trailing zeros) - Update API dump (toPlainString removed from public API) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove toPlainString from Android API dump (was missed by apiDump task) - Add [Unreleased] changelog entry documenting the removal of toPlainString and the trailing zeros preservation as breaking changes with migration guide Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the toPlainString addition and migration guide from 0.2.0 since it was never released. Move toString improvements to 0.2.1 as regular changes rather than breaking changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR removes Deci.toPlainString() from the public API and standardizes all string rendering through toString(), with the intent that toString() is plain-decimal (no scientific notation) and preserves trailing zeros.
Changes:
- Removed
toPlainString()from theexpectAPI and platform actuals; updated call sites to usetoString(). - Updated JVM/Android to preserve trailing zeros by removing
stripTrailingZeros()in string constructors and delegatingtoString()toBigDecimal.toPlainString(). - Updated tests, sample app, API dumps, and documentation/CHANGELOG for the breaking change.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sample/composeApp/src/commonMain/kotlin/org/kimplify/screens/ValidationScreen.kt | Updates sample serialization UI to compare via toString() instead of toPlainString(). |
| docs/superpowers/specs/2026-03-27-remove-toplainstring-design.md | Adds design spec describing the API removal and new toString() guarantees. |
| docs/superpowers/plans/2026-03-27-remove-toplainstring.md | Adds an implementation plan/checklist for the migration and platform changes. |
| deci/src/wasmJsMain/kotlin/org/kimplify/deci/Deci.kt | Removes toPlainString() and changes toString() to use toFixed() to avoid scientific notation. |
| deci/src/jvmMain/kotlin/org/kimplify/deci/Deci.kt | Preserves trailing zeros by removing stripTrailingZeros() and makes toString() plain-decimal. |
| deci/src/jsMain/kotlin/org/kimplify/deci/Deci.kt | Removes toPlainString() and changes toString() to use toFixed() to avoid scientific notation. |
| deci/src/commonTest/kotlin/org/kimplify/deci/math/DeciMathExtendedTest.kt | Migrates test call site to toString(). |
| deci/src/commonTest/kotlin/org/kimplify/deci/bulk/DeciBulkOperationsTest.kt | Migrates test call site to toString(). |
| deci/src/commonTest/kotlin/org/kimplify/deci/DeciTest.kt | Updates expectations for division scale and trailing-zero preservation; removes toPlainString() usages. |
| deci/src/commonTest/kotlin/org/kimplify/deci/DeciSerializationTest.kt | Migrates assertion from toPlainString() to toString(). |
| deci/src/commonTest/kotlin/org/kimplify/deci/DeciPropertyTest.kt | Migrates copy-construction to use toString(). |
| deci/src/commonMain/kotlin/org/kimplify/deci/validation/DeciValidation.kt | Migrates validation logic/messages to toString(). |
| deci/src/commonMain/kotlin/org/kimplify/deci/math/DeciMath.kt | Migrates significant-digit rounding to use toString(). |
| deci/src/commonMain/kotlin/org/kimplify/deci/formatting/DeciFormatting.kt | Migrates formatting helpers to use toString(). |
| deci/src/commonMain/kotlin/org/kimplify/deci/extension/DeciExtensions.kt | Migrates utility methods (scale, precision, etc.) to use toString(). |
| deci/src/commonMain/kotlin/org/kimplify/deci/DeciSerializer.kt | Serializes using toString() and updates KDoc accordingly. |
| deci/src/commonMain/kotlin/org/kimplify/deci/Deci.kt | Removes toPlainString() from expect and updates toString() KDoc to reflect new contract. |
| deci/src/appleMain/kotlin/org/kimplify/deci/Deci.kt | Removes Apple actual fun toPlainString(). |
| deci/src/androidMain/kotlin/org/kimplify/deci/Deci.kt | Preserves trailing zeros by removing stripTrailingZeros() and makes toString() plain-decimal. |
| deci/api/jvm/deci.api | Updates API dump to remove toPlainString() from the JVM public API. |
| deci/api/android/deci.api | Updates API dump to remove toPlainString() from the Android public API. |
| CHANGELOG.md | Documents breaking changes and migration guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Division test: assert value equality instead of string representation, since scale propagation in toString() varies by platform - Trailing zeros test: assert numeric equivalence and round-trip instead of exact string form, since scale tracking differs across platforms Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add extractScale() utility to parse scale from normalized decimal strings
- JS/wasmJs/Apple string constructors now store _scale from input
- JS/wasmJs/Apple / operator now passes policy.fractionalDigits as _scale
- Restore strong cross-platform test assertions for trailing zeros and
division scale in toString()
This ensures Deci("1.50").toString() returns "1.50" and division results
include the full policy scale on all platforms, not just JVM/Android.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deci("1.50").toString()now returns"1.50"(removedstripTrailingZeros()from JVM/Android constructors)toString()never uses scientific notation on any platform (JVM delegates toBigDecimal.toPlainString(), JS/wasmJs usetoFixed())toPlainString()— was added in 0.2.0 but never published to Maven, so no breaking change for users.toString()is the single string representation method.Test plan
allTestsacross all targets (JS, wasmJs, native)