In my TI BASIC program on TI 84 plus C, I have a line that says remainder((A/X),2)
. This creates a domain error every time the program runs. In the case of my tests, A/X is 4. remainder(4,2)
works. 4->Z remainder(Z,2)
works. If I pause the program and display (A/X) immediately before the remainder line, the result is certainly 4. (A/X)->Z remainder(Z,2)
does not work.
What could possibly be wrong with my code?
link to the code:
https://drive.google.com/open?id=0B07yHA0-EssLUjZOc0dxektwbUU
https://drive.google.com/open?id=0B07yHA0-EssLSFlNcFNWZm0zNDQ
Here is a valid substitution for remainder()
.
2fPart(A/(2X))
This works because the general form, KfPart(A/K)
takes the fractional part of A/K, which will be the same as remainder(A,K)
if A is an integer. TI-BASIC doesn't always return an integer value. For example, logBASE(16,2)
is ever so slightly less than 4. When we multiply by K
, we change the range from being 0 to 1, to 0 to K.
Nothing is inherently wrong with your code, it is TI-BASIC that is sometimes wrong.