Technical FAQs

Ask a Question

When using the REAL_TO_INT in Unity Pro, the rounding does not seem correct. 1.5 rounds to 2.0 and 2.5 also rounds to 2.0 instead of 3.0.

Goals and Symptoms

To achieve proper rounding when converting REAL numbers to INT using Unity.

Facts and Changes

The ZEF file was created using Unity Version 7.0

Causes and Fixes

Attached are two documents. One is a PDF created from Unity Help explaining how the IEC 559 rounding works and the other is a ZEF file of an example REAL to INT conversion that will work as the customer might expect. You can run it in the simulator. It first uses a block to ADD 0.5 to the REAL number and then uses a REAL_TRUNC_INT on the result. Using this, the x.5 will always round up to the next number.



Was this helpful?
What can we do to improve the information ?