From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 107f24,626a0a064b320310 X-Google-Attributes: gid107f24,public X-Google-Thread: f4fd2,626a0a064b320310 X-Google-Attributes: gidf4fd2,public X-Google-Thread: 1164ba,626a0a064b320310 X-Google-Attributes: gid1164ba,public X-Google-Thread: 103d24,626a0a064b320310 X-Google-Attributes: gid103d24,public X-Google-Thread: 114809,626a0a064b320310 X-Google-Attributes: gid114809,public X-Google-Thread: 10259a,626a0a064b320310 X-Google-Attributes: gid10259a,public X-Google-Thread: 103376,ea8ea502d35ca2ce X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-31 12:22:51 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!easynews!hermes2.visi.com!news-out.visi.com!ruti.visi.com!not-for-mail Newsgroups: comp.lang.ada,comp.lang.lisp,comp.lang.smalltalk,comp.lang.basic,comp.lang.functional,comp.lang.scheme,comp.lang.perl Subject: Re: Beginner's Language? References: <3B166490.98133E58@ftw.rsc.raytheon.com> From: thornley@visi.com (David Thornley) Message-ID: Date: Thu, 31 May 2001 19:22:50 GMT NNTP-Posting-Host: 209.98.98.8 X-Complaints-To: abuse@visi.com X-Trace: ruti.visi.com 991336970 209.98.98.8 (Thu, 31 May 2001 14:22:50 CDT) NNTP-Posting-Date: Thu, 31 May 2001 14:22:50 CDT Xref: archiver1.google.com comp.lang.ada:7950 comp.lang.lisp:11089 comp.lang.smalltalk:10382 comp.lang.functional:6007 comp.lang.scheme:4088 comp.lang.perl:3072 Date: 2001-05-31T19:22:50+00:00 List-Id: In article <3B166490.98133E58@ftw.rsc.raytheon.com>, Wes Groleau wrote: > >> P.S. Any language where you can add two positive numbers together and get a >> negative number is inherently broken. It is a sign of the language designer >> and compiler writer choosing their own convenience over yours. > >Since Java was not one of the many newsgroups posted to, >I presume it is not the only language with such a stupid >feature? > It's fairly usual in C. The C standard leaves the case of arithmetic overflow in signed types undefined, which means that the result could be negative, imaginary, text, or armed with thermonuclear weapons for all the standards care. Most systems I've used it on will wrap around, so that adding positive numbers and overflowing the limits will give you a negative number. Partly the choice of languages depends on such things as whether you wish to get the right answer almost immediately or the wrong one with even greater speed. I never want to have to trust intermediate results not to overflow, which is one of the many reasons I like Common Lisp (in which case such overflow yields the right answer at a loss in speed). Other interesting behaviors are truncation on the left because somebody left a 9 off a variable definition in COBOL. I've seen that cost thousands of dollars (well, to be honest, the client being billed probably saw it as a savings of thousands of dollars). I've heard of such behavior in PL/I, a language I have never had the pleasure of working in. You can also avoid some floating-point errors in Common Lisp by using rational numbers instead of floating-point. (/ 1 3) evaluates to an honest 1/3 rather than a floating-point approximation. If (+ (/ 1 3) (/1 3) (/1 3)) doesn't yield 1, your CL system has problems. Pity about transcendental functions that have rational values on only a few points of their range. -- David H. Thornley | If you want my opinion, ask. david@thornley.net | If you don't, flee. http://www.thornley.net/~thornley/david/ | O-