473,799 Members | 3,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dealing with hex

Is there an ideal approach to dealing with the FutureWarning about getting
the hex value of a negative int? I'm using zlib.crc32() which can return
a negative 32-bit int value, so for example print '%x' % zlib.crc32(
buffer ) generates the FutureWarning. I know I could jump through hoops
to coerce the int into a long that will have the same CRC, but is there some
particular recomendation for this (I looked at PEP 237, but there wasn't a
suggestion).
Jul 18 '05 #1
3 2742
On Wed, 10 Dec 2003 03:49:16 GMT, Matt Gerrans wrote:
Is there an ideal approach to dealing with the FutureWarning about getting
the hex value of a negative int? I'm using zlib.crc32() which can return
a negative 32-bit int value, so for example print '%x' % zlib.crc32(
buffer ) generates the FutureWarning. I know I could jump through hoops
to coerce the int into a long that will have the same CRC, but is there some
particular recomendation for this (I looked at PEP 237, but there wasn't a
suggestion).


Hoops? For example :
print "%x" % long( zlib.crc32( buffer ) )

That seems simple enough to me.

--
If your life is a hard drive,
Christ can be your backup.

www: http://dman13.dyndns.org/~dman/ jabber: dm**@dman13.dyn dns.org
Jul 18 '05 #2
Derrick 'dman' Hudson <dm**@dman13.dy ndns.org> wrote in message news:<6c******* *****@dman13.dy ndns.org>...
On Wed, 10 Dec 2003 03:49:16 GMT, Matt Gerrans wrote:
Is there an ideal approach to dealing with the FutureWarning about getting
the hex value of a negative int? I'm using zlib.crc32() which can return
a negative 32-bit int value, so for example print '%x' % zlib.crc32(
buffer ) generates the FutureWarning. I know I could jump through hoops
to coerce the int into a long that will have the same CRC, but is there some
particular recomendation for this (I looked at PEP 237, but there wasn't a
suggestion).


Hoops? For example :
print "%x" % long( zlib.crc32( buffer ) )

That seems simple enough to me.


Or if you wanted the old semantics:

def unsigned(n):
return n & 0xFFFFFFFFL

print "%x" % unsigned(zlib.c rc32(buffer))
Jul 18 '05 #3
Derrick 'dman' Hudson wrote:
Hoops? For example :
print "%x" % long( zlib.crc32( buffer ) )

That seems simple enough to me.
Simple indeed. In fact it's so simple it doesn't work:
print "%x" % long( zlib.crc32('tes t') )
-278081f4

Dan Bishop wrote: Or if you wanted the old semantics:

def unsigned(n):
return n & 0xFFFFFFFFL

print "%x" % unsigned(zlib.c rc32(buffer))


This avoids the FutureWarning, but the PEP mentions that the L-suffix
notation will also be phased out, so I wanted to avoid that in the solution
and that can be done like this:

def unsigned32(n): return n & 4294967295

since the large decimal of 0xffffffff value will automatically be a long.

It seems kind of clunky to have to throw this extra function call into the
mix whenever dealing with 32-bit values. I don't think 32-bit values will
be made obsolete by 64-bit systems for quite a while to come. This
particular update to Python seems a little pie-in-the-sky and un-pragmatic.
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2226
by: Fazer | last post by:
Hello, I have the following code: #!/usr/local/bin/python import cgi import Cookie C = Cookie.SimpleCookie() C = "f"
5
1646
by: Tom Willis | last post by:
How are the expert pythoneers dealing with config files? Is there anything similair to .net's config files or java's .properties? A quick search on google didn't return anything that looked useful, and I almost would expect to see some module that would be for dealing with config information. I can think of at least one way to do it, but I'm sure there are shortcomings I can't see yet, and I'd rather use something someone
44
3793
by: flyingfred0 | last post by:
A small software team (developers, leads and even the manager when he's had time) has been using (wx)Python/PostgreSQL for over 2 years and developed a successful 1.0 release of a client/server product. A marketing/product manager has brought in additional management and "architecture" experts to propose moving the entire thing to a Java (application server) platform for the next release. They want a "scalable, enterprise solution"...
1
2424
by: news.microsoft.com | last post by:
Hello group, My goal is to attach an image over another image. Top image should be transparent so the back image is visible through the top one. Bellow is a test code in VB.NET. You need to create a form, a button (Button1) and an Picture Box (picBox). "watermark.jpg" is any jpg image, "beispiel.tif" is a multipage TIFF image with the white background, which will turn to transparent. The most important thing here is that the TIFF image...
2
2320
by: malcolm | last post by:
Hello, We have a robust (.NET 1.1 c# winforms) client-server application that utilizes many typed DataSets, typed DataTables and typed DataRows. Our application is a series of windows and popup windows where you can edit information and data, nothing out of the ordinary. I estimate we have something like 50 to 100 tables and/or views in our database each of which map to one strongly typed DataTable. Now we have some odd 20 to 30 typed...
1
1676
by: Igor Kramarsich - EDIT | last post by:
I'm having problems dealing with dates in my queries/SQL code. I need a search digit date. In form define date field without format I receive results. But I go to define date filed with short date format I receive error. In my regional settings are in the format "dd.mm.yyyy". What I need to do?
16
2045
by: pereges | last post by:
ok so i have written a program in C where I am dealing with huge data(millions and lots of iterations involved) and for some reason the screen tends to freeze and I get no output every time I execute it. However, I have tried to reduce the amount of data and the program runs fine. What could possibly be done to resolve this ?
2
2928
by: none | last post by:
All, I was wondering is their a way of dealing with subStatusCode's with in the webconfig file? I unfortunately don't have access to anything other then webconfig and qould perfer to set in code rater then my webhost's control panel. I've even tried: <customErrors mode="On" defaultRedirect="/pages/error.aspx" />
0
9964
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Programs dealing with autoruns Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list programs that help me to view/modify the autoruns on my Windows PC? Ans: Other than Sysinternals Autoruns, there are only a few programs which are good enough to be used when dealing with autoruns. For more information about Sysinternals Autoruns, read Que-7 in Windows Autorun FAQs: Description....
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10243
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.