Skip to content

Define floatmin, floatmax, maxintfloat and issubnormal for Dual instances - #855

Open
devmotion wants to merge 2 commits into
masterfrom
dw/dual-float-constants
Open

devmotion wants to merge 2 commits into
masterfrom
dw/dual-float-constants

Conversation

@devmotion

Copy link
Copy Markdown
Member

Fixes #852.

Following JuliaLang/julia#63451, typemin, typemax, floatmin, floatmax and maxintfloat accept instances as well as types. Base only forwards instances of AbstractFloat to the type methods, so floatmin(::Dual), floatmax(::Dual) and maxintfloat(::Dual) threw a MethodError. So did maxintfloat(::Type{<:Dual}) and issubnormal(::Dual).

These functions now return the primal, which is what eps already did, and they're defined together with eps in one loop. Before, typemin/typemax/floatmin/floatmax returned a Dual with zero partials, which only added overhead and could produce NaNs.

🤖 Generated with Claude Code

@devmotion devmotion linked an issue Sep 30, 2026 that may be closed by this pull request
@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.22%. Comparing base (70ef06c) to head (8c66edc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #855      +/-   ##
==========================================
- Coverage   91.24%   91.22%   -0.02%     
==========================================
  Files          11       11              
  Lines        1085     1083       -2     
==========================================
- Hits          990      988       -2     
  Misses         95       95              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

devmotion and others added 2 commits November 3, 2026 22:43
…ual` instances (#852)

`typemin`, `typemax`, `floatmin`, `floatmax` and `maxintfloat` now return
the primal for both `Dual` instances and types instead of a `Dual` with
zero partials, which only added overhead and could produce NaNs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devmotion
devmotion force-pushed the dw/dual-float-constants branch from b0d87da to 8c66edc Compare November 3, 2026 21:45
devmotion added a commit that referenced this pull request Nov 3, 2026
- Drop the redundant `<:Real` bounds and share the constant-`a` check
- Bump version to 1.5.1 (on top of #855)
- Test the gradient of `DiffResults.hessian!`, which uses nested duals
- Test the derivative at `x = 0` for `a = 1` (from #862)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

missing floatmin, floatmax, and issubnormal for Dual

1 participant