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

math.c : probable error in square_root function #5

Open
spocino opened this issue Aug 2, 2021 · 1 comment
Open

math.c : probable error in square_root function #5

spocino opened this issue Aug 2, 2021 · 1 comment

Comments

@spocino
Copy link

spocino commented Aug 2, 2021

the square_root function has logic like so:

int i;
for (i < 0; i < 20; i++) {
// doesn't matter
}

this is almost definitely errant behavior.
try i = 0; rather than i < 0;

@pomettini
Copy link
Owner

Thanks @spocino for pointing that out. To be fair, the code is very old and I didn't know what I was doing at that time. Unfortunately by initialising the index to zero, the behaviour of the program changes completely, due to a loss of floating point accuracy. The GameBoy Advance doesn't support floating point calculation natively, and the devkitpro implementation is (probably) doing some heavy optimisations underneath that makes undefined behaviour really hard to debug. If I would write this code again, it would 100% use integers instead, but If anyone is up for investigating about this matter, I'll be happy to accept its pull request!

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

2 participants