I was attempting to test an example program that uses the intrinsic ABS() function built into the Atari Pascal Language System. The function doesn't seem to give the correct results.
Here is a simple test program TESTABS.
Given the integer number -151, I'd expect the ABS() function to return an integer value of 151. But it returns 32617.
My own quick and dirty (with no error or range checking) ABS2() function returns what I expected.
I tried passing the ABS() function a negative number < -128. Still, the result is incorrect.
I tried passing the ABS() function a REAL number, but the compiler choked on that, so I commented it out.
I'm not sure if this is a bug or an overflow issue. I need to double check the documentation and do some more testing with this function.
No comments:
Post a Comment