Please guys in java how do i call a variable whose value is a decimal and i want to subtract it from a variable that is an int. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please guys in java how do i call a variable whose value is a decimal and i want to subtract it from a variable that is an int.

10th Mar 2021, 4:59 PM
Victor Okereafor
Victor Okereafor - avatar
2 Answers
+ 3
By decimal, did you mean floating point value like 123.45? If so, you can simply assign the subtraction result into another variable e.g. <floating-point-var> = <floating-point-var> - <integer-var>; Tell some more if you're facing a problem. I'm not too sure if this was what you seek for.
10th Mar 2021, 5:17 PM
Ipang
0
Ex: Victor Okereafor int i=10; double j=5.0; i = (int)(i - j); // need casting to int back... System.out.print(i); Post code snippet which is troubling you....
10th Mar 2021, 5:32 PM
Jayakrishna 🇮🇳