openframeworks / openframeworks/openFrameworks
ofClamp() doesn't clamp NaN
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
ofClamp() doesn't clamp NaN's on my platform (Xcode 7.2).
Not sure if it's academically supposed to or not, so this might not be an issue... But I feel it should, I can't really see a case where you want to keep a NaN value around, especially considering the OF target audience.
float a = std::numeric_limits<double>::quiet_NaN();
cout << a << endl; //prints Nan
a = ofClamp(a, 0, 1);
cout << a << endl; //prints Nan
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the ofClamp() implementation and any existing tests or platform-specific handling for floating-point values. Confirm the expected behavior for quiet_NaN inputs, then add coverage and ensure the behavior is consistent with the agreed expectation across supported platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100