Rounding in formula

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tothewine
    Active Community Member
    • Jan 2018
    • 407

    #1

    Rounding in formula

    How do I get a formula without rounding?
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1815

    #2
    By default calculating interger and float happens without rounding. In float, you have to set the needed amount of decimals in the field itself.

    Comment

    • tothewine
      Active Community Member
      • Jan 2018
      • 407

      #3
      this is the result of this formula

      suPrezzoPromo = number\format((((importoOffertaIvaEsclusa/prezzoCodiceIvaEsclusa)-1)*100));


      Click image for larger version

Name:	image.png
Views:	0
Size:	9.9 KB
ID:	123779
      with this field setting

      Click image for larger version

Name:	image.png
Views:	0
Size:	18.8 KB
ID:	123780

      Comment

      • shalmaxb
        Senior Member
        • Mar 2015
        • 1815

        #4
        Guessing from your example, you have an article with normal price, which you offer also as promo with a percentage (both adding% and substracting% ??).

        So from the normal price you set any + or - percentage and then want to display the promo price.

        If this is the case, you do not need formatting formula, it is more simple:

        PHP Code:
        suPrezzoPromo normalPrice + ((normalPrice/100)*percentValue); 
        If you input a positive value, the percentage amount will be added to the normal price. If you input a negative value, it will be substracted.

        Your examples, calculated with this formula:

        5420,00 1% 5474,20
        4000,00 -5% 3800,00
        3800,00 18% 4720,00
        3800,00 0% 3800,00

        I hope it helps.

        Comment

        Working...