Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4262
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!198.186.194.247.MISMATCH!news-out.readnews.com!transit3.readnews.com!panix!not-for-mail |
|---|---|
| From | Grant Edwards <invalid@invalid.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: NaN |
| Date | Thu, 28 Apr 2011 20:39:51 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 28 |
| Message-ID | <ipcjan$pv8$1@reader1.panix.com> (permalink) |
| References | <BANLkTine8W15e=SqNnJUStMNdy2GGA9pUA@mail.gmail.com> <mailman.945.1304010112.9059.python-list@python.org> |
| NNTP-Posting-Host | dsl.comtrol.com |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Trace | reader1.panix.com 1304023191 26600 64.122.56.22 (28 Apr 2011 20:39:51 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Thu, 28 Apr 2011 20:39:51 +0000 (UTC) |
| User-Agent | slrn/pre0.9.9-102 (Linux) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:4262 |
Show key headers only | View raw
On 2011-04-28, Chris Rebert <clp2@rebertia.com> wrote:
>> 2. What are the use cases for NaN? Looks like it gets used a lot as a
>> numeric (float?) object with non-value.
>
> FWICT, it's useful in lower-level languages (which typically lack
> exceptions and often lack nice ways of returning multiple values from
> a function) as a convenient way of signaling a mathematical error.
When doing stuff involving process control systems, I found it very
useful to use NaN to indicate "unknown/invalid". It propogates
properly through calculations so that when you have an invalid input,
all of the outputs that depend on it also go invalid.
The other option is to use a value/status tuple everywhere you would
normally use a float. But that falls over every time you need to use
a library function that expects a float as an input and returns a
float as an output.
Since the sensors return a NaN when the value is unkown/invalid it
seemed logical to continue with that paradigm in my Python code -- and
it pretty much "just works".
--
Grant Edwards grant.b.edwards Yow! If elected, Zippy
at pledges to each and every
gmail.com American a 55-year-old
houseboy ...
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar
Re: NaN Chris Rebert <clp2@rebertia.com> - 2011-04-28 10:01 -0700
Re: NaN Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-28 18:59 +0000
Re: NaN Terry Reedy <tjreedy@udel.edu> - 2011-04-28 17:23 -0400
Re: NaN Grant Edwards <invalid@invalid.invalid> - 2011-04-28 21:56 +0000
Re: NaN Grant Edwards <invalid@invalid.invalid> - 2011-04-28 20:39 +0000
csiph-web