Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Compare generics (that are numbers) Date: Thu, 30 Jul 2020 09:03:14 -0400 Organization: A noiseless patient Spider Lines: 24 Message-ID: References: <87k0ym73id.fsf@munus.decebal.nl> <87ft9a6u35.fsf@munus.decebal.nl> <87bljy6qu3.fsf@munus.decebal.nl> <87zh7h5ouj.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 30 Jul 2020 13:03:17 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="3a3532b4fb7317e8571e5c02d58681f5"; logging-data="852"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19c0wgv/RwholZsqsgfbJmm" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cancel-Lock: sha1:kg+TzfqY42fexGYQlR4HpI8NV+E= In-Reply-To: <87zh7h5ouj.fsf@munus.decebal.nl> Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:39601 On 7/30/2020 5:33 AM, Cecil Westerhof wrote: > Arne Vajhøj writes: > >> But if this is performance critical then why not just drop the >> generic stuff and write specific code for the types? > > Because I want to show the differences between using > Float/float/Integer/int and different implementations thereof. Is this a "practical problem," or a "teaching exercise?" If the former, I'd be interested to know how it arises -- needing to compare one arbitrary Number to another (BigDecimal vs. AtomicLong?) seems not out of the question, but surely unusual. If it's a teaching tool, you might want to reconsider the vehicle. As has been pointed out, some combinations (DoubleAdder vs. BigInteger, others) raise a lot of thorny and niggling special cases that might tend to obscure whatever point you're trying to put across. Maybe if folks had a better idea of the goals they'd suggest better approaches. -- esosman@comcast-dot-net.invalid If he's so rich, why ain't he smart? One hundred seventy-four days to go.