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

Replace hex floating point literals #172

Merged
merged 1 commit into from Dec 4, 2020
Merged

Conversation

SanderMertens
Copy link
Contributor

No description provided.

@recp
Copy link
Owner

recp commented Dec 2, 2020

@SanderMertens thanks for the PR,

Maybe we should use a MACRO instead of that literal everywhere?

I found this comment (https://community.khronos.org/t/math-function-fract/1181/2):

It’s a hexadecimal float constant as supported by C99, and it is indeed the largest number < 1.0 which can be represented as single precision float. It’s probably written with the 1 before the decimal point because that’s how IEEE754 floats are actually stored, with an implicit leading 1 (unless it’s a denormalized number). Then fffffe means all 23 mantissa bits are set to 1.

and this: https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/fract.html

also this (http://www.mitsuba-renderer.org/api/constants_8h_source.html):

#if defined(__WINDOWS__)
#define ONE_MINUS_EPS_FLT 0.999999940395355225f
#define ONE_MINUS_EPS_DBL 0.999999999999999888
#define RCPOVERFLOW_FLT   2.93873587705571876e-39f
#define RCPOVERFLOW_DBL   5.56268464626800345e-309
#else
#define ONE_MINUS_EPS_FLT 0x1.fffffep-1f
#define ONE_MINUS_EPS_DBL 0x1.fffffffffffff7p-1
#define RCPOVERFLOW_FLT   0x1p-128f
#define RCPOVERFLOW_DBL   0x1p-1024
#endif

it would be nice to use 0x1.fffffep-1f where it can possible and other value ( 0.999999940395355224609375f) for everywhere else

@recp
Copy link
Owner

recp commented Dec 4, 2020

I'll accept this PR and will update it later, thanks for your contribution 🎉

@recp recp merged commit 34e7438 into recp:master Dec 4, 2020
@recp recp added todo and removed todo labels Dec 4, 2020
@SanderMertens
Copy link
Contributor Author

Thanks! Sorry, I didn't have the time yesterday to update it.

@recp
Copy link
Owner

recp commented Dec 4, 2020

@SanderMertens sorry, I should have waited a bit more :) next time 🤗

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.

None yet

2 participants