A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-October/069186.html below:

[Python-Dev] Caching float(0.0)

[Python-Dev] Caching float(0.0)Gregory P. Smith greg at electricrain.com
Tue Oct 3 21:47:06 CEST 2006
> > It would be instructive to understand how much, if any, python code  
> > would break if we lost -0.0.  I'm do not believe that there is any  
> > reliable way for python code to tell the difference between all of  
> > the different types of IEEE 754 zeros and in the special case of -0.0  
> > the best test I can come up with is repr(n)[0]=='-'.  Is there an  
> > compelling case, to do with compatibility or otherwise, for exposing  
> > the sign of a zero?  It seems like a numerical anomaly to me.
> 
> I think it is reasonable to admit that
> a) this change is a change in semantics for the majority of the
>    machines
> b) it is likely that this change won't affect a significant number
>    of applications (I'm pretty sure someone will notice, though;
>    someone always notices).

If you're really going to bother doing this rather than just adding a
note in the docs about testing for and reusing the most common float
values to save memory when instantiating them from external input:

Just do a binary comparison of the float with predefined + and - 0.0
float values or any other special values that you wish to catch rather
than a floating point comparison. 

-g

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4