Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31449
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Martin Gregorie <martin@address-in-sig.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Simple if-exercises |
| Date | Fri, 3 Apr 2015 19:31:15 +0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 39 |
| Message-ID | <mfmpq3$2tt$2@dont-email.me> (permalink) |
| References | <if-20150402020010@ram.dialup.fu-berlin.de> <mfjhvg$1ka$1@dont-email.me> <mflc17$mdd$1@Gaia.teknon.de> <mflq2e$nsq$1@dont-email.me> <mfmkp4$3ga$1@Gaia.teknon.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Fri, 3 Apr 2015 19:31:15 +0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="3005"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+R8r2aP1BVnj99cM4uGv26yH2CcVcTk0w=" |
| User-Agent | Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) |
| Cancel-Lock | sha1:cMaRi3CAuYuLuk2w9XfKAb11hEo= |
| Xref | csiph.com comp.lang.java.programmer:31449 |
Show key headers only | View raw
On Fri, 03 Apr 2015 18:05:24 +0000, Volker Borchert wrote:
> Martin Gregorie wrote:
>> On Fri, 03 Apr 2015 06:29:59 +0000, Volker Borchert wrote:
>>
>> > Jeff Higgins wrote:
>> >
>> >> Why don't we have a Quinary operator?
>> >> x ? y LT : EQ : GT
>> >
>> > One of those occasions where "newer" is not "better".
>> >
>> > I _do_ miss FORTRAN's three-way IF statement.
>>
>> It would be more in the style of Java to extend the switch statement's
>> syntax by adding pseudo constants corresponding to <, == and > so you
>> could write something like:
>>
>> switch(arithmetic expression)
> sgn( )
>
I think you meant Math.signum() - sgn isn't Java, its a VBA/Excel/Access
function.
But in any case using Math.signum() looks kind of messy by the time
you've called the static function and then coerced its result to integer:
switch((int)Math.signum(n))
{
case -1:
case 0: s = "Negative-or-equal"; break;
case +1: s = "Positive"; break;
default: s = "Defaulted";
}
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Simple if-exercises Jeff Higgins <jeff@invalid.invalid> - 2015-04-02 09:58 -0400
Re: Simple if-exercises Jeff Higgins <jeff@invalid.invalid> - 2015-04-02 10:53 -0400
Re: Simple if-exercises Jerry Stuckle <jstucklex@attglobal.net> - 2015-04-02 15:08 -0400
Re: Simple if-exercises Gene Wirchenko <genew@telus.net> - 2015-04-02 16:46 -0700
Re: Simple if-exercises v_borchert@despammed.com (Volker Borchert) - 2015-04-03 06:29 +0000
Re: Simple if-exercises Martin Gregorie <martin@address-in-sig.invalid> - 2015-04-03 10:29 +0000
Re: Simple if-exercises v_borchert@despammed.com (Volker Borchert) - 2015-04-03 18:05 +0000
Re: Simple if-exercises Martin Gregorie <martin@address-in-sig.invalid> - 2015-04-03 19:31 +0000
Re: Simple if-exercises Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-04-03 16:07 -0400
Re: Simple if-exercises Martin Gregorie <martin@address-in-sig.invalid> - 2015-04-03 21:45 +0000
Re: Simple if-exercises v_borchert@despammed.com (Volker Borchert) - 2015-04-03 23:49 +0000
Re: Simple if-exercises Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-04-03 07:38 -0400
Re: Simple if-exercises Jeff Higgins <jeff@invalid.invalid> - 2015-04-03 20:06 -0400
csiph-web