At the last tech meeting Dan presented Parrot. Thanks Dan. The runtime interpreter for Perl 6 (and friends) is now at the same state as every other interpreter: it permits a programmer to write a buggy program. :) Because Dan mentionned "cache lines" twice I did not have to ask about that, and someone else brought up .NET.
Then Uri briefly described his plan to write a module to support BCD arithmetic. The question arose as to what names should be used to indicate the range of numbers that can be represented. I recommend using the following names, taken from the XML Schema spec: totalDigits and fractionDigits. Their meaning is obvious to most people; contrast this with precision and scale. (To avoid a naming convention debate I could easily accept a more perlish total_digits, etc.) Google found many pages on the topic of BCD arithmetic. The following goes into great detail and also has commented code to test validity, do ten's complement, and subtraction. <quote from = " http://www.cs.uiowa.edu/~jones/bcd/bcd.html " > add(a,b) t1 = a + 0x06666666 t2 = t1 + b t3 = t1 ^ b t4 = t2 ^ t3 t5 = ~t4 & 0x11111110 t6 = (t5 >> 2) | (t5 >> 3) return t2 - t6 Here, the addition used to form t1 should not produce any carries, since we assume that t1 is valid. The addition used to form t2 will produce a carry exactly when the decimal addition of two digits in the operands would produce a carry, and these are the carries we are concerned with. In t2, the digits in each position that produced a carry will have the correct value, but the digits in positions that did not produce a carry will contain an excess 6. The problem, then, is to remove the extra 6 from each digit that did not generate a carry. ... etc. </quote> This is for a 4 byte (but only 7 significant digits) number. Uri's proposal to support arbitrary totalDigits should be straightforward. Hopefully helpfully yours, Steve -- Steven Tolkin [EMAIL PROTECTED] 617-563-0516 Fidelity Investments 82 Devonshire St. V10D Boston MA 02109 There is nothing so practical as a good theory. Comments are by me, not Fidelity Investments, its subsidiaries or affiliates.
