[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: assignment inside boolean expression*From*: Ben Tupper <tupper(at)seadas.bigelow.org>*Date*: Tue, 11 Jul 2000 12:07:50 -0400*Newsgroups*: comp.lang.idl-pvwave*Organization*: Bigelow Laboratory for Ocean Sciences*References*: <396A3790.43C8EB31@astro.psu.edu> <396A429E.4367BEA9@ssec.wisc.edu> <396B18EE.DC2E38DD@seadas.bigelow.org> <ond7kkitqx.fsf@cow.physics.wisc.edu>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:20194

Craig Markwardt wrote: > Ben Tupper <tupper@seadas.bigelow.org> writes: > > "Liam E.Gumley" wrote: > > > > > > > > Recall that in IDL, integers with odd non-zero values are Boolean > > > 'True'. Beware of floats and doubles though, where any non-zero value is > > > Boolean 'True'. > > > > > > > Dang! > > > > I just spent an hour figuring out an efficient way of determining if an > > integer is odd! > > > > I have an IDL function ISODD() for sale... very cheap. No reasonable > > offer refused. > > Not to undercut you, but will (X AND 1) do the trick? > Thanks to Ken and Craig. I think for my purposes the following should suffice (I guess as long as I make sure that I'm working with an integer/long/byte type.) X = Indgen(6) - 2 For i = 0, N_elements(X)-1 Do $ If X[i] then Print, X[i], ': Odd' Else print, X[i], ': Even' -2: Even -1: Odd 0: Even 1: Odd 2: Even 3: Odd Thanks again, Ben -- Ben Tupper Bigelow Laboratory for Ocean Science tupper@seadas.bigelow.org pemaquidriver@tidewater.net

**Follow-Ups**:**Re: assignment inside boolean expression***From:*Martin Schultz

**References**:**assignment inside boolean expression***From:*Patrick Broos

**Re: assignment inside boolean expression***From:*Liam E.Gumley

**Re: assignment inside boolean expression***From:*Ben Tupper

**Re: assignment inside boolean expression***From:*Craig Markwardt

- Prev by Date:
**Re: assignment inside boolean expression** - Next by Date:
**problems with cw_form in IDL5.3** - Prev by thread:
**Re: assignment inside boolean expression** - Next by thread:
**Re: assignment inside boolean expression** - Index(es):