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

ftoa fails (and unsafe) for floats > INT32_MAX #21

Open
jeromekelleher opened this issue Jul 12, 2024 · 3 comments
Open

ftoa fails (and unsafe) for floats > INT32_MAX #21

jeromekelleher opened this issue Jul 12, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@jeromekelleher
Copy link
Contributor

The decimal value for FLT_MAX is 340282346638528859811704183484516925440, which is much larger than we currently support. We need some way to either support this, or to protect the underlying C code.

@jeromekelleher jeromekelleher added the bug Something isn't working label Jul 12, 2024
@jeromekelleher
Copy link
Contributor Author

For reference, htslib uses kputd which is quite a bit more complex.

I think the right approach here is to use the existing code for the common cases, and fallback onto sprintf("%f") when the magnitude of the value is outside the range we want to deal with. Detecting this will be fiddly, though.

@tomwhite - what was the rationale for limiting the int32 + three digits in the numba implementation?

@tomwhite
Copy link
Contributor

Could we eventually use/follow kputd?

what was the rationale for limiting the int32 + three digits in the numba implementation?

It was basically covering the common cases - leaving open the option of a wider range of magnitudes (scientific notation) for later, see sgkit-dev/sgkit#966 (and sgkit-dev/sgkit#953).

@jeromekelleher
Copy link
Contributor Author

Adapting kputd will have it's own issues probably, but yeah, that may be the simplest route.

@jeromekelleher jeromekelleher added this to the Initial release milestone Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants