I have a variable which contain the textfield value. I want to multiply that x value with a decimal number like 0.013. But after multiplication I got as answer 0.
It takes the decimal value as 0. What is the reason?
I have a variable which contain the textfield value. I want to multiply that
Share
In a comment, the OP notes
This suggests that the problem is in how the value is initialized:
4/3is integer division, returning theintvalue1. The solution is to be sure that the calculations are actually dealing with floats, start to finish, by using float literals, e.g., replacing4/3with4.0/3.0