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

Open
runer112 opened this issue Dec 26, 2023 · 2 comments
Open

__ultof actually implements __ltof #466

runer112 opened this issue Dec 26, 2023 · 2 comments
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant