Skip to content

Commit 1597c8e

Browse files
committed
fix(PackedBitVector): fix unpack_floats not scaling by integer size
1 parent 61f34d2 commit 1597c8e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

UnityPy/helpers/PackedBitVector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def unpack_floats(
8282

8383
# read as int and cast up to double to prevent loss of precision
8484
quantized_f64 = unpack_ints(packed, start, count)
85-
quantized = [x * packed.m_Range + packed.m_Start for x in quantized_f64]
85+
scale = packed.m_Range / ((1 << packed.m_BitSize) - 1)
86+
quantized = [x * scale + packed.m_Start for x in quantized_f64]
8687
return reshape(quantized, shape)
8788

8889

0 commit comments

Comments
 (0)