String.jack

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

String.jack

John Douma
I have a couple of questions about String.jack and StringTest.

1. There is a test case where 0 memory is allocated. If I use my Memory.jack, all is well. If I use the built-in Memory module, I get an error that says memory allocated must be positive. Is this a bug in the built-in module or are the requirements for the project version and the built-in version different?

2. According to the book and the StringTest output, the newLine and backSpace characters should have ascii values of 128 and 129, respectively. I was always under the impression that ascii values ranged from 0 to 127, i.e. 8 bits with the most significant bit being 0. What am I missing? I looked up newLine and backSpace and I get 10 and 8, respectively
Reply | Threaded
Open this post in threaded view
|

Re: String.jack

cadet1620
Administrator
John Douma wrote
I have a couple of questions about String.jack and StringTest.

1. There is a test case where 0 memory is allocated. If I use my Memory.jack, all is well. If I use the built-in Memory module, I get an error that says memory allocated must be positive. Is this a bug in the built-in module or are the requirements for the project version and the built-in version different?
I made sure that my String.jack never tries to allocate 0 bytes of memory.  If String.new(0) is called, I adjust maxLength so that Array.new won't blow up.
2. According to the book and the StringTest output, the newLine and backSpace characters should have ascii values of 128 and 129, respectively. I was always under the impression that ascii values ranged from 0 to 127, i.e. 8 bits with the most significant bit being 0. What am I missing? I looked up newLine and backSpace and I get 10 and 8, respectively
Strictly speaking ASCII does not have a "new line" control code.  It has "carriage return" (13) and "line feed" (10).  Unix derived systems use LF as newline, Macs use CR, Windows uses CR,LF.  TECS chose to use 128 and 129 for new line and back space.  As long as the codes are used consistently, it doesn't really matter what their numeric values are.
(I would not have called it ASCII if I were writing the book, just "character codes".)

--Mark