Dividing by 100 returns 0

后端 未结 6 1869
一向
一向 2021-01-17 02:13

I just wanted to calculate the VAT, but when i divide by 100 to obtain the total price (price*VAT/100), but it returns me 0.0. Here\'s my code:

        a.pri         


        
6条回答
  •  一生所求
    2021-01-17 02:58

    You need to cast the expression to float. I used a float literal here 100.0f.

    a.total= a.precio*a.iva/100.0f;
    

提交回复
热议问题