ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl5-porters
perl5-porters
RE: [ID 20010723.001] perl 5.6.1: BigInt booleans cannot handle
by Miller, Scott L other posts by this author
Jul 24 2001 2:13PM messages near this date
Re: [ID 20010723.001] perl 5.6.1: BigInt booleans cannot handle | Re: [ID 20010723.001] perl 5.6.1: BigInt booleans cannot handle
>  -----Original Message-----

>  From: Nicholas Clark [mailto:nick@[...].org]

>  

>  On Mon, Jul 23, 2001 at 09:08:42PM +0200, Tels wrote:

>  > I am unsure how to repeat this. The result of -1 & -1 

>  > highly depends on the

>  > width of a Perl scalar. Since Bigint is by definition 

>  > "infinite width", the

>  > result should probably be something like +inf :-) 

>  > Seriously, I do not know

>  > how to repeat Perl's behaviour without assuming a specific 

>  > width. Anyway,

>  > your program looking for -1 & -1 beeing 4294967295 will fail on any

>  > platform not having 32 bit (like 64 bit).

>  > 

>  > Has anybody any comments or ideas on what to do?

>  

>  Not sure if this is a sane idea. Can you

>  

>  define the width of a negative integer to be the smallest 

>  number of bits

>  needed to represent it in 2s complement.

>  So -9 (ie 1111111111110111) is 10111 (width 5)

>  

>     -6 (ie 1111111111111010) is 1010 (width 4)

>  

>  -6 & -9 needs to promote -6 to width 5, [same as positive 

>  case] but do the

>  promotion as sign extension (11010) then & the two together

>  

>  11010 & 10111 == 10010

>  

>  which is -14. And gives the same answer as 16 bit and 32 bit 

>  fixed precision,

>  as best I can tell.

>  

>  [not tested very much for other values or for | or ^ operators]

>  

>  Nicholas Clark


How would you be able to tell if the number was intended to be negative?
11010 = -6 or 26, 10111 = -9 or 23...

-Scott
Thread:
Miller, Scott L

John Peacock

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved