-
Notifications
You must be signed in to change notification settings - Fork 0
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
INT() of a negative number truncates toward 0, unlike C65 and C64 #164
Comments
The new INT() behavior started in 920177. Versions between 173 and 183 didn't get individual commits, so the change is somewhere in here: https://github.com/MEGA65/mega65-rom/commit/8b5b60d3b6b5587bdff409861a3315bd674a6b70 The comment in The previous definition is here: https://github.com/MEGA65/mega65-rom/blob/4e15b7dc57d0ae9468786b4a993e8a31a271a7a3/b65.src#L12281 Or more specifically, this I'm actually a little torn now. If this really was intended as "The Greatest Integer Function," then all Commodore BASICs had this wrong, and this was a fix. I'm wary of replacing a piece of Commodore BASIC so fundamental, but maybe we consider keeping it? |
c65manualupdated.txt says:
which is unhelpfully contradictory in the case of negative numbers. :) |
Very useful C64 wiki page: https://www.c64-wiki.com/wiki/Floating_point_arithmetic
|
As of ROM 920408,
INT(-1.5)
returns -1, and generally demonstrates truncation toward zero. This is unlike the C65 910828 and C64, which truncate toward negative infinity, e.g.INT(-1.5)
returns -2.BASIC65 should be consistent with the C65 and C64 behaviors. It's likely that this behavior also messes up some bitplane graphics features, though I don't have a specific one to mention. I tried to draw a COS() graph the other day and saw some erroneous cowlicks in the negative areas, but I haven't researched the actual cause.
The text was updated successfully, but these errors were encountered: