2
I’m training statistics so I started doing a little program to calculate the percentile. The problem/bug occurs during division always returning 0 even with variables having values.
public static void main(String[] args) throws Exception {
Float[] valores = new Float[] { 2f, 2f, 3f, 4f, 4f, 9f };
System.out.println(percentilIgualAbaixo(valores, 3));
}
public static int percentilIgualAbaixo(Float[] array, float value) {
List<Float> arr = Arrays.asList(array);
int indexValue = arr.lastIndexOf(value) + 1;
System.out.println("Index value:" + indexValue);
System.out.println("tamanho list:" + arr.size());
return indexValue / arr.size();
}
Exit:
Index value:3
tamanho list:6
0
ah understood thank you.
– Arthur Santiago