On Fri, 2 Dec 2005, James Newtons Massmind wrote: > > On Dec 2, 2005, at 7:55 AM, Olin Lathrop wrote: > > > > > There's enough public misunderstanding about this concept that it's > > > important (in fact irresponsible not to) for us engineers and > > > scientists to state it correctly. This sort of erroneous statement > > > and imprecise use of terms needs to be squashed whenever > > possible to > > > avoid even more confusion and misunderstanding by non-technical > > > people. > > > > Yeah, I found the whole discussion back in Jr High about > > precision and significant digits very enlightening, and try > > to keep it in mind. The public misunderstanding shows up > > pretty clearly when you get something like conversion from > > english fractional units to metric decimal units. > > 1.5875 mm indeed. Hah! > > > > BillW > > > Any yet there is not a SINGLE computer language that tracks the actual > precision of calculations! E.g. When you multiply 1 byte times another 1 > byte the result should be stored in 2 bytes. If you add 1 bytes to another 1 > byte, the result should be stored in 2 bytes with only the lowest bit of the > second byte used. > > http://www.sxlist.com/techref/expeval2.asp is my poor attempt to do such a > thing. Play with it and tell me why programmers don't demand that ability in > their compilers? XCSB doesn't go the whole hog but it does track this much better than C. e.g. byte_var = byte_var + byte_var // see (1) byte_var = byte_var + word_var // see (2) word_var = byte_var + byte_var // see (3) byte_var = (byte_var + byte_var) >> k // see (4) byte_var = (ubyte)(byte_var + byte_var) >> k // see (5) (1) ... add operation performed as two bytes (2) ... add operation performed as two bytes (3) ... add operation performed as two words (4) ... add operation performed as two words shift operation performed on word result (5) ... add operation performed as two bytes shift operation performed on byte result XCSB takes the aproach that it wont store values bigger than the declared size of a variable but it will allocate temporary storage to handle intermediate results which are bigger than the destination of a calculation. Also comparing signed and unsigned works correctly e.g. if unsigned_byte_var > signed_byte_var then always true if unsigned_byte_var > 127 always false if signed_byte_var < 0 otherwise true or false as expected endif Regards Sergio Masci http://www,xcprod.com/titan/XCSB - optimising PIC compiler FREE for personal non-commercial use . -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist