Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!ulysses!ggs From: ggs@ulysses.att.com (Griff Smith) Newsgroups: comp.lang.c++ Subject: Re: MININT problem with C++ streams Summary: fixed in 2.0 Keywords: c++,C++,MININT,streams Message-ID: <13407@ulysses.att.com> Date: 12 Jul 90 21:24:33 GMT References: <1959@runxtsa.runx.oz.au> Organization: AT&T Bell Laboratories, Murray Hill Lines: 29 In article <1959@runxtsa.runx.oz.au>, edward@runxtsa.runx.oz.au (Edward Birch) writes: | MININT is not printed out correctly by some Glockenspiel and AT&T C++ compilers. This may have been a problem with the AT&T 1.2 release, but it works on my system with the 2.1 release. | I think the bug is caused by an assumption in the C++ library | going something like: | | if (v < 0) { | emit_char('-'); | v = -v; // clearly wrong when v = MININT with | // (2's complement arithmatic) | } | | Edward Birch | Phone: (02) 958-2119 | | UUCP: seismo!munnari!runx.oz!edward ACSnet: edward@runx.oz | ARPA: edward%runx.oz@seismo.css.gov CSNET: edward@runx.oz Actually, it isn't wrong on a 2's complement machine if the `v = -v' operation doesn't cause an overflow trap. The trick is to cast the resulting number to unsigned and then do the conversion. -- Griff Smith AT&T (Bell Laboratories), Murray Hill Phone: 1-201-582-7736 UUCP: {most AT&T sites}!ulysses!ggs Internet: ggs@ulysses.att.com