diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/nir/nir_algebraic.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py index 6b8c881803b..a84c41a78f9 100644 --- a/src/compiler/nir/nir_algebraic.py +++ b/src/compiler/nir/nir_algebraic.py @@ -139,7 +139,16 @@ class Constant(Value): if isinstance(self.value, (int, long)): return hex(self.value) elif isinstance(self.value, float): - return hex(struct.unpack('Q', struct.pack('d', self.value))[0]) + i = struct.unpack('Q', struct.pack('d', self.value))[0] + h = hex(i) + + # On Python 2 this 'L' suffix is automatically added, but not on Python 3 + # Adding it explicitly makes the generated file identical, regardless + # of the Python version running this script. + if h[-1] != 'L' and i > sys.maxsize: + h += 'L' + + return h else: assert False |