Title: Wrong RoundUp-&gt;RoundDown
Last modified: July 12, 2018

---

# Wrong RoundUp->RoundDown

 *  Resolved [Toto146](https://wordpress.org/support/users/toto146/)
 * (@toto146)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/wrong-roundup-rounddown/)
 * Hi there,
 * using PREC((fieldname21*0.5),2) brings me a wrong result by rounding wrong.
 * E.G.: 150,55 * 0,5 = 72,275 -> Result from CFF 72,27. But I need it to round 
   up from 5 to 9.
 * Thanks for your help
 * Thorsten

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/wrong-roundup-rounddown/#post-10487558)
 * Hello [@toto146](https://wordpress.org/support/users/toto146/),
 * You can use the following operation instead:
 * PREC(ROUND(fieldname21*0.5,0.01),2)
 * PREC(fieldname21*0.5, 2) is quivalent to the javascript code: (fieldname21*0.5).
   toFixed(2)
 * Best regards.
 *  Thread Starter [Toto146](https://wordpress.org/support/users/toto146/)
 * (@toto146)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/wrong-roundup-rounddown/#post-10490102)
 * Hello [@codepeople](https://wordpress.org/support/users/codepeople/),
 * thanks for your fast reply. I’ve tried the new formula but now the result for
   the example in the opening thread
 * What I need is the correct round like in this example:
 * 161,95€ * 0,5 = 80,975€ -> cff rounds down to 80,97€ -< I need the correct rounding
   to 80,98€
 * Using the new formula makes out of 161,95€ * 0,5 = 81,00€.
 * What can I do?
 * Kind regards
    Thorsten
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/wrong-roundup-rounddown/#post-10490480)
 * Hello [@toto146](https://wordpress.org/support/users/toto146/),
 * Are you sure that the equation was included using the second parameter in the
   ROUND operation?
 * I’ve tested the equation with the structure I sent you in the previous ticket
   and the number 161.95, used in your example, and the result is 80.97
 * Please, look the screenshot visiting the following link:
 * [https://wordpress.dwbooster.com/customdownloads/2018/07/13/screenshot_equation.png](https://wordpress.dwbooster.com/customdownloads/2018/07/13/screenshot_equation.png)
 * Best regards.
 *  Thread Starter [Toto146](https://wordpress.org/support/users/toto146/)
 * (@toto146)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/wrong-roundup-rounddown/#post-10490678)
 * Hello [@codepeople](https://wordpress.org/support/users/codepeople/),
 * I’ve tried this in console also but my result you can see in the [attachment](https://abschleppdienst-heinrich.de/wp-content/uploads/round_issue.JPG).
   Crazy.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/wrong-roundup-rounddown/#post-10490920)
 * Hello [@toto146](https://wordpress.org/support/users/toto146/),
 * The second parameter of the “ROUND” operation was included in the latest updates
   of the plugin, so, I guess you are using a previous version of the plugin on 
   your website. Please, update your copy of the plugin and try again.
 * Best regards.
 *  Thread Starter [Toto146](https://wordpress.org/support/users/toto146/)
 * (@toto146)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/wrong-roundup-rounddown/#post-10570629)
 * Hello [@codepeople](https://wordpress.org/support/users/codepeople/) ,
 * now after an update the result from
 * PREC(ROUND(161.95*0.5,0.01),2) is 80,97.
 * But this is still not the result that I need.
 * 161,95 / 2 = 80,975 -> this must be rounded up to 80.98.
 * Reaching a 5 should round up to the next full result. E.g. 20,255 = 20,26
 * Thanks in advance,
    Thorsten
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/wrong-roundup-rounddown/#post-10570793)
 * Hello [@toto146](https://wordpress.org/support/users/toto146/),
 * The operation: ROUND(80.975,0.01) is equivalent in basic javascript to:
 *     ```
       Math.round(80.975*100)/100 = 
       Math.round(8097.5)/100 = 8097/100 = 80.97
       ```
   
 * as you can see, unfortunately the Javascript engine rounds the number 8097.5 
   as 8097 and not 8098
 * The alternative is a simple trick:
 * Modifies your operation as follows:
 *     ```
       PREC(ROUND(161.95*0.5+0.000000001,0.01),2)
       ```
   
 * The sum does not affects the operation, but solves the ambiguity.
 * Best regards.
 *  Thread Starter [Toto146](https://wordpress.org/support/users/toto146/)
 * (@toto146)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/wrong-roundup-rounddown/#post-10588294)
 * Hi [@codepeople](https://wordpress.org/support/users/codepeople/),
 * that was the trick!!!
 * Thanks!
 * Best regards
    Thorsten

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Wrong RoundUp->RoundDown’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

## Tags

 * [CFF](https://wordpress.org/support/topic-tag/cff/)
 * [Rounding](https://wordpress.org/support/topic-tag/rounding/)

 * 8 replies
 * 2 participants
 * Last reply from: [Toto146](https://wordpress.org/support/users/toto146/)
 * Last activity: [7 years, 9 months ago](https://wordpress.org/support/topic/wrong-roundup-rounddown/#post-10588294)
 * Status: resolved