EliotVU / Unreal-Library

UnrealScript decompiler library for Unreal package files (.upk, .u, .uasset; etc), with support for Unreal Engine 1, 2, and 3
MIT License
359 stars 85 forks source link

Floating imprecision #52

Open EliotVU opened 2 years ago

EliotVU commented 2 years ago

Floats are sometimes not formatted properly, especially if they have many decimals e.g.

Script: splashSize = 0.000025 * Mass * (250 - 0.5 * Velocity.Z); Compiled->Decompiled to: splashSize = (2.5E-05 * Mass) * (float(250) - (0.5 * Velocity.Z));

The decompilation of floats is handled at PropertyDisplay

Solution: Changing the format to "F7" outputs 0.0000250, however this also outputs BobDamping=0.96 as BobDamping=0.9600000, using "G7" gives us a compact output, but it doesn't fix the first problem 👎🏻

Should we just strip the trailing zeros? Or is there a way to get the results of F7 in a compact form like G7?