www.delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2014/01/31/17:09:19

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
X-Envelope-From: paubert AT iram DOT es
Date: Fri, 31 Jan 2014 23:08:45 +0100
From: Gabriel Paubert <paubert AT iram DOT es>
To: geda-user AT delorie DOT com
Subject: Re: [geda-user] Re: refdes renumber
Message-ID: <20140131220845.GA29613@visitor2.iram.es>
References: <CACPio-66SHLWYAusnwq0acYBL+QX0uwuuT8zeUotYE90a5pCHQ AT mail DOT gmail DOT com>
<CAG4ve9KeBYS_Gs_5y2o6ZWVREq0tEFtJiEQbX692SbRzTdSxgw AT mail DOT gmail DOT com>
<CAG4ve9+wP0VAnXAFpB+gJQHUphnNTYn71_wBphuMafL09k9YnQ AT mail DOT gmail DOT com>
<koto2c$r5i$1 AT ger DOT gmane DOT org>
<CAG4ve9KJeGATHFoUuosCnOeUNa9TcunM1+C9EJwxAbTQ3yU0dw AT mail DOT gmail DOT com>
<kp224q$20f$1 AT ger DOT gmane DOT org>
<CAG4ve9+RgrKFe7-F13QxMqb4sx3jYqQuaFxwzPnVuayPq9U8fw AT mail DOT gmail DOT com>
<1391182300 DOT 2023 DOT 11 DOT camel AT AMD64X2 DOT fritz DOT box>
<CAG4ve9+JF25kq5xzZ0NyAF2cK2Sq_qBEUK742aj64ZrQmituWg AT mail DOT gmail DOT com>
<dcctraxft DOT ln2 AT skate DOT rswarbrick>
MIME-Version: 1.0
In-Reply-To: <dcctraxft.ln2@skate.rswarbrick>
User-Agent: Mutt/1.5.20 (2009-06-14)
X-Spamina-Bogosity: Ham
Note-from-DJ: This may be spam
Reply-To: geda-user AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: geda-user AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Fri, Jan 31, 2014 at 08:07:09PM +0000, Rupert Swarbrick wrote:
> Алексей Харьковский <svetonomer-Re5JQEeQqe8AvxtiuMwx3w AT public DOT gmane DOT org>
> writes:
> > This is simple:
> > In [20]: ~0
> > Out[20]: -1
> 
> For other readers who (like me) are being slow today, the ~ operator
> performs unary bitwise NOT. Apparently, integers in Python are
> explicitly two's complement.

I don't even know if there are still non two's complement machines
being manufactured. And if these exotic beasts do exist, Python
has probably not been ported to them. Basically today, all machines
you can afford to buy use 2's complement integer, have word sizes 
which are a power of 2, and use IEEE-754 floating point. 

Well, IBM mainframes (not that an individual can afford one) still 
allow to use the original S/360 hexadecimal FP format, but they also 
support IEEE FP (plus decimal floating point for comercial workloads). 

This said, there is another important point: for an array of n 
elements, valid indices in Python are in the range from -n to 
n-1. The range 0 to n-1 is the familiar zero-based indexing used in
C and other languages, negative indices run backwards from the
end of the array so a[-n] is the first element and a[-1] the last.

[Note that I don't think that this definition is a good idea: it 
may hide bugs when you have a complex indexing expression which 
is off by one and the Python interpreter will happily access the 
last element of an array instead of throwing an exception for
out of bounds access. There are cases where it is handy but I am 
of the strong opinion that it is more dangerous than useful.]

	Gabriel

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019