Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6786
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: float("nan") in set or as key |
| References | <mailman.2351.1306897552.9059.python-list@python.org> <b7b526f5-c839-4b3e-8e00-eee8a19078ce@glegroupsg2000goo.googlegroups.com> <mailman.2354.1306900680.9059.python-list@python.org> |
| Date | 2011-06-01 15:18 +1000 |
| Message-ID | <87ei3e6sen.fsf@benfinney.id.au> (permalink) |
| Organization | Unlimited download news at news.astraweb.com |
Chris Angelico <rosuav@gmail.com> writes: > Right. Obviously a true 'real number' representation can't be done. > But there are multiple plausible approximations thereof (the best > being rationals). Sure. But most of those are not what is most commonly meant by ‘float’ type. > Not asking for Python to be changed, just wondering why it's defined > by what looks like an implementation detail. Because, in the case of the ‘float’ type, the agreed-upon meaning of that type – in Python as in just about every other language that is well-specified – is “an IEEE float as per the IEEE 754 spec”. A foolish consistency to the spec would be a hobgoblin for little minds. But, given that a ‘float’ type which deviated from that spec would just be inviting all sorts of other confusion, it's not a foolish consistency. > It's like defining that a 'character' is an 8-bit number using the > ASCII system, which then becomes problematic with Unicode. Right. That's why in Python 3 the Unicode text type is called ‘unicode’, the IEEE float type is called ‘float’, and the byte string type is called ‘bytes’. It's also why the ‘str’ type in Python 2 was painful enough to need changing: it didn't clearly stick to a specification, but tried to straddle the worlds between one specification (a text type) and an incompatible other specification (a bytes sequence type). Where there is a clearly-defined widely-agreed specification for a type, it's a good idea to stick to that specification when claiming to implement that functionality in a type. -- \ “The man who is denied the opportunity of taking decisions of | `\ importance begins to regard as important the decisions he is | _o__) allowed to take.” —C. Northcote Parkinson | Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: float("nan") in set or as key Carl Banks <pavlovevidence@gmail.com> - 2011-05-31 20:30 -0700
Re: float("nan") in set or as key Roy Smith <roy@panix.com> - 2011-05-31 23:43 -0400
Re: float("nan") in set or as key Grant Edwards <invalid@invalid.invalid> - 2011-06-01 14:04 +0000
Re: float("nan") in set or as key Chris Angelico <rosuav@gmail.com> - 2011-06-01 13:57 +1000
Re: float("nan") in set or as key Ben Finney <ben+python@benfinney.id.au> - 2011-06-01 15:18 +1000
Re: float("nan") in set or as key Jerry Hill <malaclypse2@gmail.com> - 2011-06-01 09:44 -0400
Re: float("nan") in set or as key Chris Angelico <rosuav@gmail.com> - 2011-06-02 02:12 +1000
csiph-web