Update Float16ToFloat32.py for python3
Bug: angleproject:40096762
Change-Id: I0925a06f229f011e8c272e25e8ea33c2d490049a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/7071919
Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
diff --git a/src/common/Float16ToFloat32.py b/src/common/Float16ToFloat32.py
index 592da65..7ee794e 100644
--- a/src/common/Float16ToFloat32.py
+++ b/src/common/Float16ToFloat32.py
@@ -15,12 +15,11 @@
return 0
elif i < 1024:
m = i << 13
- e = 0
+ e = 0x38800000
while not (m & 0x00800000):
e -= 0x00800000
m = m << 1
m &= ~0x00800000
- e += 0x38800000
return m | e
else:
return 0x38000000 + ((i - 1024) << 13)
@@ -48,7 +47,7 @@
return 1024
-print """//
+print("""//
// Copyright 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -56,29 +55,31 @@
// This file is automatically generated.
+#include "common/mathutil.h"
+
namespace gl
{
-"""
+""")
-print "const static unsigned g_mantissa[2048] = {"
+print("const static unsigned g_mantissa[2048] = {")
for i in range(0, 2048):
- print " %#010x," % convertMantissa(i)
-print "};\n"
+ print(" %#010x," % convertMantissa(i))
+print("};\n")
-print "const static unsigned g_exponent[64] = {"
+print("const static unsigned g_exponent[64] = {")
for i in range(0, 64):
- print " %#010x," % convertExponent(i)
-print "};\n"
+ print(" %#010x," % convertExponent(i))
+print("};\n")
-print "const static unsigned g_offset[64] = {"
+print("const static unsigned g_offset[64] = {")
for i in range(0, 64):
- print " %#010x," % convertOffset(i)
-print "};\n"
+ print(" %#010x," % convertOffset(i))
+print("};\n")
-print """float float16ToFloat32(unsigned short h)
+print("""float float16ToFloat32(unsigned short h)
{
unsigned i32 = g_mantissa[g_offset[h >> 10] + (h & 0x3ff)] + g_exponent[h >> 10];
return bitCast<float>(i32);
}
}
-"""
+""")