Finding .5 decimals while rounding

Hello everybody, we need to round .5 decimals down and the rest to the nearest. For example: 1.4 → 1 1.5 → 1 1.6 → 2 this is because we have to integrate Navision with other system that does this calculations, and we get wrong numbers when in a customer order appear “.5” numbers. We cannot use the ROUND function, since it rounds .5 up when using ‘nearest’ (default). If we could detect these, we could use the ROUND up or down as needed, but we don´t know how to find “.5” decimals. Any suggestion will be appreciated. Thank you very much in advance.

If you use ROUND it will always round up 0.5 to 1 but you could use ROUND(x-0.01) to get the result you are looking for. Paul Baxter

The decimal portion of a number can be determined easily by number MOD 1 You could then test for 0.5 and round accordingly.

Why don’t use Direction i the ROUND function? NewNumber := ROUND(Number [, Precision] [, Direction]) NewNumber Data type: decimal The rounded result. Number Data type: decimal The number you want to round. Precision Data type: decimal This optional parameter determines the precision used when rounding off. The default value is 0.01 for the US version. In other countries, other default values may be used. Direction Data type: text or code This optional parameter tells the system how to round Number. The default rounding method is ‘=’. You can change the method using these options: Enter this… To round… ‘=’ To the nearest value (default) ‘>’ Up ‘<’ Down Example The following example shows how to use the ROUND function. DN := 1234.56789; Larger := ‘>’; Precision := 0.001; Res := ROUND(DN, Precision, Larger); MESSAGE(‘ROUND(%1, %2, %3) returns %4’,DN, Precision, Larger,Res); The message window shows: ROUND(1,234.56789, 0.001, >) returns 1,234.568 This table shows some additional ROUND examples: Number Precision Direction NewNumber 100 = 1200 0.1 = 1234.6 1234.56789 0.001 = 1234.568 0.001 < 1234.567 0.001 > 1234.568 100 = -1200 0.1 = -1234.6 -1234.56789 0.001 = -1234.568 0.001 < -1234.567 0.001 > -1234.568 Per.Bay@navigera.com Product Manager www.navigera.com

You can obtain the rounding you desire by subtracting 0.5 and rounding up.

Thank you everybody, we finally decided to use the way Paul Baxter introduced, but to obtain the desired results in all situations, we used the formula: ROUND(Amount - Currency.“Amount Rounding Prec.”/100, Currency.“Amount Rounding Prec.”); where needed. That gives us the desired round with all currencies. Regards.