Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.help Subject: Re: Reverse sorting an array Date: Sat, 01 Oct 2011 22:58:44 -0400 Organization: A noiseless patient Spider Lines: 28 Message-ID: References: <8ea2add1-ce9c-423b-bdb8-92c461cf9c6d@5g2000yqo.googlegroups.com> <5ff0ec30-9ffe-4513-ac55-c5d16f141399@u6g2000vbo.googlegroups.com> <1jjf871i3ug6e4fui8aaanln5h21r17m0h@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 2 Oct 2011 02:59:25 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="f8igmItKsWs6nM5YanFxAA"; logging-data="8960"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jL3pzA2CNoVRpm18aEZvG" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 In-Reply-To: <1jjf871i3ug6e4fui8aaanln5h21r17m0h@4ax.com> Cancel-Lock: sha1:qYiDy0wIiPXobLpD6HlqOTrKNQg= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:1180 On 10/1/2011 10:38 PM, Roedy Green wrote: > On Fri, 30 Sep 2011 20:50:33 -0400, Eric Sosman > wrote, quoted or indirectly quoted > someone who said : > >> * Negate every element of the array, use Arrays.sort() to put the >> array in ascending order, and then negate all the elements again. >> (Note that this won't work if Integer.MIN_VALUE appears in the >> array, because Integer.MIN_VALUE == -Integer.MIN_VALUE.) > oops > > because Integer.MIN_VALUE != -Integer.MIN_VALUE "I meant what I said, and I said what I meant." But if you don't believe me, try it yourself: public class Asymmetry { public static void main(String[] unused) { System.out.println(Integer.MIN_VALUE == -Integer.MIN_VALUE); } } Welcome to the world of fixed-precision two's complement arithmetic. -- Eric Sosman esosman@ieee-dot-org.invalid