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

__ultof actually implements __ltof #466

Closed
runer112 opened this issue Dec 26, 2023 · 3 comments · Fixed by #564
Closed

__ultof actually implements __ltof #466

runer112 opened this issue Dec 26, 2023 · 3 comments · Fixed by #564
Assignees

Comments

@runer112
Copy link
Member

runer112 commented Dec 26, 2023

And __ltof implements a worse __ltof.

Example code demonstrating issue:

#include <ti/getcsc.h>
#include <ti/screen.h>

#include <limits.h>
#include <stdio.h>

void testl(long x) {
  printf("%11li -> %11.0f", x, (float)x);
}

void testul(unsigned long x) {
  printf("%11lu -> %11.0f", x, (float)x);
}

int main() {
  os_ClrHome();

  testl(LONG_MAX);
  testl(LONG_MIN);
  testl(ULONG_MAX);
  os_NewLine();
  testul(LONG_MAX);
  testul(LONG_MIN);
  testul(ULONG_MAX);

  while (!os_GetCSC())
    ;
}

image

@runer112
Copy link
Member Author

__ultof and __ltof are both implemented as if __fppack accepts an unsigned 32-bit integer input, but it actually expects a signed 32-bit integer input.

@runer112
Copy link
Member Author

Discovered by 418cat: https://discord.com/channels/432891584451706892/432891584875593730/1188975936603947069.

@runer112 runer112 self-assigned this Dec 26, 2023
@ZERICO2005
Copy link
Contributor

ZERICO2005 commented Mar 25, 2025

it also seems that __fppack will rounds up ties instead of rounding to even
937097632ul should round to even 937097600.0f, not upwards to 937097664.0f

@adriweb adriweb linked a pull request Mar 25, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants