Re: List.sortBy shows wrong result
Chris <[email protected]> Thu, 25 Feb 2016 01:06:45 -0800 (PST)
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
Yes, but why does this affect the sort order? Am Donnerstag, 25. Februar 2016 09:37:10 UTC+1 schrieb David Starner: > > The negation of -21474836848 in 32-bit two's complement arithmetic is > -21474836848. There is no positive value corresponding to the negative of > the minimal value in two's complement arithmetic. > > On Wed, Feb 24, 2016, 11:56 PM Chris <[email protected] <javascript:>> > wrote: > >> Hi all, >> >> >> List.sortBy show a strange behaviour: >> >> val l = List(Int.MinValue, Int.MinValue+1) >> l.sortBy(I => I) // List(-2147483648, -2147483647) >> l.sortBy(I => -I) // List(-2147483648, -2147483647) >> >> >> If I use other values anything seems ok >> >> val l = List(Int.MinValue+2, Int.MinValue+1) >> l.sortBy(I => I) // List(-2147483647, -2147483646) >> l.sortBy(I => -I) // List(-2147483646, -2147483647) >> >> >> What's wrong here? >> Can anyone help? Thanks in advance. >> >> Chris >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "scala-language" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "scala-language" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.