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

Roku handles hexadecimal as signed integer #14

Open
lvcabral opened this issue Sep 13, 2023 · 0 comments
Open

Roku handles hexadecimal as signed integer #14

lvcabral opened this issue Sep 13, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@lvcabral
Copy link
Collaborator

This code:

color = &HC0C0C0FF
print color

Shows in Roku console as: -1061109505
Shows in brs console as: 3233857791

Quote by RokuKC from the forum (link below)

here are some somewhat subtle issues with respect to specifying integer constants and how type conversions and limit checks are performed.

Hex constants can represent a full 32-bit unsigned range of integers (0 .. &hFFFFFFFF - 4,294,967,295), as overlaid on a 32-bit signed integer variable. Values outside that range get clipped to 32-bits.

Integer constants should represent a full 32-bit signed range, but the current behavior is to only represent integer -999,999,999 .. 999,999,999. Values outside that range get implicitly promoted to type Double.

However, if you pass that Double value to an integer-typed parameter, or assign it to an integer-typed variable, it goes through a narrowing conversion back to signed integer. The value is out of range and in this case happens to be converted to an out of range value &h80000000, which happens to look like a reddish color value.

https://forums.roku.com/viewtopic.php?f=34&t=84652

@lvcabral lvcabral added the bug Something isn't working label Sep 13, 2023
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

1 participant