Skip to content

Commit 4c77431

Browse files
authored
Added double casting in utility
1 parent ccd5286 commit 4c77431

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cpp_extensions/solver.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void update_optimal_solution(BestUtility &best_solution, int const &feature_idx,
2626
int const &N, int const &P_bar, double const &p, double const &feature_weight,
2727
int const &n_negative, int const &n_positive){
2828
// Get utility for x > t and check if optimal
29-
double utility_0 = (N - p * P_bar) * feature_weight;
29+
double utility_0 = ((double) N - p * (double) P_bar) * feature_weight;
3030
if(best_solution < utility_0){
3131
best_solution.clear();
3232
best_solution.set_utility(utility_0);
@@ -38,7 +38,7 @@ void update_optimal_solution(BestUtility &best_solution, int const &feature_idx,
3838
// Get utility for x <= t and check if optimal
3939
int N_1 = n_negative - N;
4040
int P_bar_1 = n_positive - P_bar;
41-
double utility_1 = (N_1 - p * P_bar_1) * feature_weight;
41+
double utility_1 = ((double) N_1 - p * (double) P_bar_1) * feature_weight;
4242
if(best_solution < utility_1){
4343
best_solution.clear();
4444
best_solution.set_utility(utility_1);

0 commit comments

Comments
 (0)