Skip to content

fix: use single precision for dtoa with f32#2908

Merged
CountBleck merged 10 commits into
AssemblyScript:mainfrom
mattjohnsonpint:issue-2873
Feb 8, 2025
Merged

fix: use single precision for dtoa with f32#2908
CountBleck merged 10 commits into
AssemblyScript:mainfrom
mattjohnsonpint:issue-2873

Conversation

@mattjohnsonpint

@mattjohnsonpint mattjohnsonpint commented Feb 6, 2025

Copy link
Copy Markdown
Contributor

Fixes #2873

Changes proposed in this pull request:

Adjusts dtoa and dtoa_buffered to accept either f32 or f64. Implementation details borrowed from Kotlin.

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@mattjohnsonpint
mattjohnsonpint marked this pull request as draft February 6, 2025 17:57
@mattjohnsonpint
mattjohnsonpint marked this pull request as ready for review February 6, 2025 18:36
@mattjohnsonpint
mattjohnsonpint marked this pull request as draft February 6, 2025 18:40
@mattjohnsonpint

This comment was marked as outdated.

@mattjohnsonpint
mattjohnsonpint marked this pull request as ready for review February 6, 2025 19:32
@mattjohnsonpint

mattjohnsonpint commented Feb 6, 2025

Copy link
Copy Markdown
Contributor Author

Haha, I just read this line in the Kotlin sources for their original implementation:

// Based on the AssemblyScript implementation [https://github.com/AssemblyScript/assemblyscript/blob/1e0466ef94fa5cacd0984e4f31a0087de51538a8/std/assembly/util/number.ts]

And then it looks like just last week, @skuzmich gave it the 32-bit precision support, for the same reasons. Seems fair to add it back here too!

(Thanks @skuzmich!)

Comment thread std/assembly/util/number.ts Outdated
Comment thread std/assembly/util/number.ts Outdated
Comment thread std/assembly/util/number.ts Outdated
Comment thread std/assembly/util/number.ts Outdated
Comment thread tests/compiler/std/string.ts
Comment thread tests/compiler/std/string.ts
Comment thread tests/compiler/std/string.ts
Comment thread tests/compiler/std/string.ts

@MaxGraey MaxGraey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@CountBleck

Copy link
Copy Markdown
Member

If @MaxGraey says it looks good, we should merge it.

Comment thread tests/compiler/std/string.ts Outdated
@CountBleck
CountBleck requested a review from MaxGraey February 7, 2025 23:50
@CountBleck
CountBleck merged commit be1d94a into AssemblyScript:main Feb 8, 2025
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.

f32 toString emits extra decimals

3 participants