Integer division error in the Java API.

Python, Java, Android OS, etc.
sveinpg
Posts: 1
Joined: Tue Sep 08, 2015 9:00 am

Integer division error in the Java API.

Postby sveinpg » Wed Nov 11, 2015 10:19 am

Hello!

I'm currently working on a BITalino application for Android using the Java SDK created by Paulo Pires. To convert the data after reading it I tried to use the SensorDataConverter-methods provided in the SDK. That's when I encountered what I believe is an error in the SDK.

Let's take the scaleLuminosity method as an example:

public static double scaleLuminosity(final int port, final int raw) {
return 100 * (raw / getResolution(port));
}

Where raw and getResolution(port) both are ints. This leads to an integer division which again will result in returning either 0.0 or 100.0, nothing in between.

Simular interger divisions are present in some of the other scaling-methods aswell, just though I should give you guys a heads up.

~ Sveinpg

Return to “Programming APIs”




cron