Created
April 13, 2012 21:16
-
-
Save Fitblip/2380242 to your computer and use it in GitHub Desktop.
Sulley issue #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
orted by [email protected], Sep 30, 2008 | |
Index: sulley/primitives.py | |
=================================================================== | |
--- sulley/primitives.py (revision 154) | |
+++ sulley/primitives.py (working copy) | |
@@ -763,6 +763,23 @@ | |
self.rendered = rendered | |
+ elif self.format == "hex": | |
+ # if the sign flag is raised and we are dealing with a signed integer (first bit is 1). | |
+ if self.signed and self.to_binary()[0] == "1": | |
+ max_num = self.to_decimal("0" + "1" * (self.width - 1)) | |
+ # chop off the sign bit. | |
+ val = self.value & max_num | |
+ | |
+ # account for the fact that the negative scale works backwards. | |
+ val = max_num - val | |
+ | |
+ # toss in the negative sign. | |
+ self.rendered = "%x" % ~val | |
+ | |
+ # unsigned integer or positive signed integer. | |
+ else: | |
+ self.rendered = "%x" % self.value | |
+ | |
# | |
# ascii formatting. | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment