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

HPDF_FToA works improperly for small values #258

Closed
Nekto89 opened this issue Dec 9, 2022 · 2 comments
Closed

HPDF_FToA works improperly for small values #258

Nekto89 opened this issue Dec 9, 2022 · 2 comments

Comments

@Nekto89
Copy link

Nekto89 commented Dec 9, 2022

Broken in #187

#include <hpdf_utils.h>
#include <stdio.h>
#include <float.h>

int main() {
    HPDF_REAL value = 1e-15f;
    char buf[65];
    char* p = HPDF_FToA(buf, value, buf + 64);
    *p = '\0';
    printf("%s", buf);
    return 0;
}

In 2.4.3: 0.000000000000000'..-
in 2.3.0: 0

@maj0e
Copy link

maj0e commented Feb 2, 2023

Encountered the same problem, when trying to draw Text rotated by 90°. I called:

HPDF_Page_Concat(cos(PI/2), sin(PI/2), -sin(PI/2), cos(PI/2), 0, 0)

where on my computer I get cos(PI/2) == 6.12323e-17 and sin(PI/2) == 1.
Unfortunately the Text is not shown at all with that transformation matrix.
Setting small values to zero or using cosf(PI/2), which evaluates to "-4.37114e-08", works fine though, so I suspect it's related to this exact issue.

@bramton
Copy link
Member

bramton commented Apr 10, 2023

@Nekto89 The issue has now been resolved. The HPDF_INT64 used for storing the integer and fractional part was not sufficiently large.

@maj0e This is related to something else. The HPDF_FToA function is used for representing a float as a char array. It seems this is fixed by #255. If the issue persists, please create a new issue.

@bramton bramton closed this as completed Apr 10, 2023
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

3 participants