PyWart: Language missing maximum constant of numeric types!

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Feb 24 17:59:16 CET 2012


On 24/02/2012 16:23, Michael Torrie wrote:
> On 02/24/2012 08:34 AM, Rick Johnson wrote:
>> Yes i could write my own implementation of INFINITY if i wanted,
>> although i would have returned True and False as apposed to 1 and 0
>> AND used the identifiers Infinity and Infinitesimal, but i digress :-
>> P.
>>
>> However, INFINITY is something i believe a language should provide;
>> which python does, albeit inconsistently.
>
> How do you represent infinity as an binary integer number?  Or are you
> suggesting that the integer type (class) be modified to allow an
> "infinity" state that really isn't a number at all (could not be stored
> as a integer in C)?

The C integer bit doesn't matter since e.g.
 >>> 
a=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 >>> a
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L

And no, I'm not going to calculate how much memory I'd need to store a 
string that's this long :)

> Float is a different story because IEEE does define a binary
> representation of infinity in the floating-point specification.
>
> I know of no language that has any form of representation of infinity
> for integers mainly because there's no way to represent infinity as a
> standard twos-compliment binary number.  In a language that deals
> directly with types in memory such as C, having an infinity
> representation would be possible but would make simple math really hard,
> and much slower.
>
> All this reminds me of the original cray supercomputers.  They didn't
> use twos compliment for integers so they had two representations of zero
> (+0 and -0).  Made programming a bit tricky.  When asked why the cray
> didn't just do two's compliment like everyone else, Seymour Cray
> responded that when the computer was designed he simply didn't know
> about twos compliment.

-- 
Cheers.

Mark Lawrence.




More information about the Python-list mailing list