# How this Float “4-bytes” is converted to Short_signed “2-bytes”? Hi, please help me on this problem, I don't understand how this Float "4-bytes" or IEEE 754 floating point, is converted to short_signed "2-bytes".

First, I convert the float "4-bytes" hexadecimal to float decimal, then I convert this float decimal to hexadecimal again. and I get the short_signed result.

But the problem when I put the normals or UVs, I get always 0.xxxx when I convert this 0.xxxx to hexadecimal doesn't give the result like the short_signed in the image or excel file.

Here is the website to convert hexadecimal to IEEE 754: https://gregstoll.com/~gregstoll/floattohex/ (check swap endianness) and the website to convert decimal to hexadecimal: https://www.rapidtables.com/convert/number/decimal-to-hex.html

Here is the full Float 4-bytes to Short_signed 2-bytes excel file for results: https://drive.google.com/open?id=1oKxVuqFVcVX3NEGLwzFvsZqXos1PwYIA

• I might be missing the point but how does it relate to RE? May 12 '20 at 15:41
• "First, I convert the float "4-bytes" hexadecimal to float decimal, then I convert this float decimal to hexadecimal again. and I get the short_signed result." That makes no sense. Add how exactly you are 'converting'. May 12 '20 at 21:26
• 1- Copy "4-bytes" hex from excel file. 2- Paste it into hex value in: gregstoll.com/~gregstoll/floattohex 3- Check swap endianness. 4- Click on convert to float. 5- Copy the float value. 6- Paste it into decimal number in: rapidtables.com/convert/number/decimal-to-hex.html 7- Click on convert. 8- And you get the "2-bytes" hex like in excel file. May 13 '20 at 13:29

One word, precision

By definition, a normal is a vector with a length of 1.0f which means that each component of the vector will always fall between -1.0f and +1.0f, and UV are texture coordinates expressed in a range between 0 and +1.0f.

The number of possible states that you can represent with this range of numbers is huge and even exceeds the total number of states in a singed short. So if you want to retain the greatest precision possible, you need to scale the value by the maximum value of a singed short.

Therefore, to obtain the correct results, you need to multiply by 32767 and then round it to the nearest integer (if it's a texture coordinate) or truncate it (if it's a normal). The rounding and truncating are just some observations I made when converting the values myself.

Example normal (using the 9th row):
X: 0x96DE = -26914 = truncate(-0.821400702 * 32767 = truncate(-26914.836802434)
Y: 0x3E17 = 13847 = truncate(0.422606796026 * 32767) = truncate(13847.556885383942)
Z: 0xCEFA = -12250 = truncate(-0.383020102978 * 32767) = truncate(-12550.419714280126)

Example UV (using the 1st row):
X: 0x64FD = 25853 = round(0.788999974728 * 32767) = round(25853.162171912376)
Y: 0x5D49 = 23881 = round(0.72879999876 * 32767) = round(23880.58955936892)