0

Tping error in example

Not a question but 15/4 is not = 3

10th May 2017, 9:01 AM
Katherine Rub
Katherine Rub - avatar
4 Answers
+ 6
depends on who you ask. ask an int and they will say it is 3. ask a float and they will say it is 3.75 http://stackoverflow.com/questions/4685450/why-is-the-result-of-1-3-0
10th May 2017, 9:13 AM
jay
jay - avatar
+ 6
15/4 is 3.75.Since computers like integers , it is 3. (Integers or int means to store a number without decimal) If you use 15f/4 or 15/4f (in java), it will give 3.75, f stands for float(which is just a data type to hold decimal numbers like 2.8 or 2.000000000264)
10th May 2017, 10:31 AM
Meharban Singh
Meharban Singh - avatar
+ 5
It is 3 @Katherine, Such expressions in (I think) every programming language results integer value (quotient only). Thus, 15/4= 3, 8/5=3 etc.
10th May 2017, 11:04 AM
Sachin Artani
Sachin Artani - avatar
0
In Java it is. If you want 3.75 you have to divide 15.0/4
10th May 2017, 9:12 AM
merkrafter