You're dividing integers, which means that you're using integer division.
In integer division the fractional part of the result is thrown away.
Try the following:
float res = (float) quantity / standard;
^^^^^^^
The above forces the numerator to be treated as a float
which in turn promotes the denominator to float as well, and a float-division is performed instead of an int-division.
Note that if you're dealing with literals, you can change
float f = 6800 / 500;
to include the f
suffix to make the denominator a float:
float f = 6800f / 500;
^
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…