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

NK_DTOA needs more documentation #699

Open
Xeverous opened this issue Sep 23, 2024 · 0 comments
Open

NK_DTOA needs more documentation #699

Xeverous opened this issue Sep 23, 2024 · 0 comments

Comments

@Xeverous
Copy link

Xeverous commented Sep 23, 2024

The current documentation states:

You can define this to dtoa or your own double to string conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!).

The problem is, there is no such function. dtoa is neither in C standard library, C++ standard library or in POSIX. I just don't know what is the "contract" of this function.

Based on Nuklear's code:

https://github.com/Immediate-Mode-UI/Nuklear/blob/ca8aaf3f65e9fc8ac5d90fefc1204585add4b89b/nuklear.h#L7116-L7117

The function takes a buffer and a value of type double and returns the end of the string in the buffer.

How large the buffer should be? I checked the implementation and found out it is NK_MAX_NUMBER_BUFFER. This constant is documented but it is easy to lose it - NK_DTOA does not mention it and does not even specify how the function should look like (and there is no standard function to look into).

IMO it should be documented that:

  • NK_DTOA relies on NK_MAX_NUMBER_BUFFER
  • what the expected function prototype is
  • what the expected behavior is (e.g. returns start or end of buffer)
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

No branches or pull requests

1 participant