Fast way of converting boolean to double

I need to convert double to boolean in java. It is happening very often in my application and it has the crucial effect on the performance of the application. Is there any way how to rewrite this method to be faster? I need to operate with doubles because precision is necessary, but instead of saving doubles, I save just boolean values (when the data can be only 0 or 1). The code is here:

public static double booleanToDouble(boolean b) {

if (b) {

return 1;


return 0;


Read More »

By: StackOverFlow - Saturday, 14 April

Related Posts