[ Table of Contents ] [ List of Example Programs ] [ INTCONST Disk Image ]
INTCONST is an example program (Listing 9-9) from page 122 of the book "Pascal Primer" by David Fox and Mitchell Waite.
The program takes an INTEGER and attempts to convert it to a STRING. It is the opposite of the VALDEMO example program. It doesn't take any input from the user. It uses the predefined value MAXINT (32767) and converts it to a STRING. This program makes use of the string INSERT procedure. It also uses the ABS function. Since the Atari Pascal built-in ABS() function is buggy, I overrode it with my own simple ABS() function.
The link command looks like:
LINKER V1.0
*D2:INTCONST,PASLIB/S
When you run the program, it looks like:
Showing posts with label ABS. Show all posts
Showing posts with label ABS. Show all posts
Friday, March 15, 2019
Thursday, March 14, 2019
VALDEMO
[ Table of Contents ] [ List of Example Programs ] [ VALDEMO Disk Image ]
VALDEMO is an example program (Listing 9-8) beginning on page 120 of the book "Pascal Primer" by David Fox and Mitchell Waite.
It takes a number as a STRING as input, tests it, and tries to convert it to an INTEGER.
I ran into a bug with the intrinsic absolute value function ABS() built into the Atari Pascal Language System. After some testing, I wrote my own quick and dirty ABS() function to override the existing buggy one.
The link command looks like:
LINKER V1.0
*D2:VALDEMO,GRSND,PASLIB/S
When you run the program, it looks like:
Wednesday, March 13, 2019
BUG: ABS()
[ Table of Contents ] [ List of Example Programs ] [ TESTABS Disk Image ]
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.
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.
Subscribe to:
Posts (Atom)





