Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: Compare generics (that are numbers) Date: Wed, 29 Jul 2020 21:53:08 +0200 Organization: Decebal Computing Lines: 37 Message-ID: <87bljy6qu3.fsf@munus.decebal.nl> References: <87k0ym73id.fsf@munus.decebal.nl> <87ft9a6u35.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="79ff8c6ea305f6a25ce9fe89b8d0bb76"; logging-data="32137"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xxPPje8ZNUC8abSzV+FZeSQb8gUahGVM=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cancel-Lock: sha1:8YgA6oncHEklz656AVPrk95w5gg= sha1:A0RgVuJhV6B6dinixIF/JnDlhAk= Xref: csiph.com comp.lang.java.programmer:39596 Arne Vajhøj writes: > On 7/29/2020 2:42 PM, Cecil Westerhof wrote: >> Eric Sosman writes: >>> On 7/29/2020 11:19 AM, Cecil Westerhof wrote: >>>> I have a class that starts with: >>>> abstract class CalcValuesGeneric { >>>> >>>> E will be Integer, int, Float or float. (For now, but always a Number.) >>>> What is the best way to determine which of the two is lower? >>> >>> Aside: How can you get `' to be `' or `'? Is that >>> something new? I'm still on Java 8, but the JLS for 14 says "Seq >>> is illegal, as primitive types cannot be type arguments." (4.5) >> >> You are completely right, I was not thinking straight. :'-( > > Probably a common miswording. > > class CalcValuesGeneric { > void something(E v) > ... > cvg.something(x); > > E can be Integer or Float but not int or float. > > But x can be int and float as well due to auto boxing. But I do not want auto boxing. The particular case I am working with shows that int can take 40% less CPU and memory when using Integer. I will find another way. Thanks. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof