Skip to content

fix: use single precision for dtoa with f32 #2908

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 10 commits into from
Feb 8, 2025

Conversation

mattjohnsonpint
Copy link
Contributor

@mattjohnsonpint mattjohnsonpint commented Feb 6, 2025

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
Copy link
Contributor Author

mattjohnsonpint commented Feb 6, 2025

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!)

Copy link
Member

@MaxGraey MaxGraey left a comment

Choose a reason for hiding this comment

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

LGTM

@CountBleck
Copy link
Member

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

@CountBleck CountBleck requested a review from MaxGraey February 7, 2025 23:50
@CountBleck CountBleck merged commit be1d94a into AssemblyScript:main Feb 8, 2025
14 checks passed
# for free to join this conversation on GitHub. Already have an account? # 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