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

casting a floating-point number to an integer #64

Open
rschumi0 opened this issue Jun 1, 2020 · 0 comments
Open

casting a floating-point number to an integer #64

rschumi0 opened this issue Jun 1, 2020 · 0 comments

Comments

@rschumi0
Copy link

rschumi0 commented Jun 1, 2020

There seems to be an issue when a cast is performed from a floating-point number that is larger than the maximum Integer to an Integer. In this case, the value should just be the largest Integer as documented in Section 5.1.3 of the JLS.
However, K-Java performs this cast in the same way as a long to int cast as illustrated by the following example.

System.out.println(((int)2147483648L));
System.out.println(((int)2147483648.0)); // should be 2147483647

The same issue also occurs for a cast to other data types when floating-point numbers are involved.

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