Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Printf: avoid converting to Float64 or BigFloat #187

Merged
merged 4 commits into from
Feb 9, 2025

Conversation

jmkuhn
Copy link
Collaborator

@jmkuhn jmkuhn commented Feb 1, 2025

Fixes #178

Currently Printf is converting DecimalFloatingPoint values to Float64 which causes issues such as

julia> @sprintf("%.36f", d64"0.1")
"0.100000000000000005551115123125782702"

julia> @sprintf("%e", floatmax(Dec64))
"Inf"

With this PR

julia> @sprintf("%.36f", d64"0.1")
"0.100000000000000000000000000000000000"

julia> @sprintf("%e", floatmax(Dec64))
"1.000000e+385"

Currently %a/%A formatting isn't implemented. I'll do that in a separate PR.

@quinnj

Copy link

codecov bot commented Feb 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.81%. Comparing base (87b39dd) to head (19cf5e0).
Report is 3 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #187       +/-   ##
===========================================
+ Coverage   80.45%   95.81%   +15.35%     
===========================================
  Files           1        2        +1     
  Lines         435      597      +162     
===========================================
+ Hits          350      572      +222     
+ Misses         85       25       -60     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/DecFP.jl Outdated Show resolved Hide resolved
@stevengj
Copy link
Member

stevengj commented Feb 9, 2025

LGTM. Merge when ready.

@jmkuhn
Copy link
Collaborator Author

jmkuhn commented Feb 9, 2025

Looks like I no longer have write access to merge. It is ready to merge.

@stevengj stevengj merged commit b0a98b2 into JuliaMath:master Feb 9, 2025
11 checks passed
@stevengj
Copy link
Member

stevengj commented Feb 9, 2025

I added you to the repo so that you should be able to merge in the future.

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.

printf is converting to Float64
2 participants