Skip to content

Commit

Permalink
Change a use of is_realzero to just is_zero
Browse files Browse the repository at this point in the history
This is needed to avoid a possible divide by zero.
  • Loading branch information
jwiegley committed Mar 23, 2023
1 parent cbc9993 commit 49cf332
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ commodity_pool_t::exchange(const amount_t& amount,
current_annotation = &as_annotated_commodity(commodity).details;

amount_t per_unit_cost =
(is_per_unit || amount.is_realzero()) ? cost.abs() : (cost / amount).abs();
(is_per_unit || amount.is_zero()) ? cost.abs() : (cost / amount).abs();

if (! cost.has_commodity())
per_unit_cost.clear_commodity();
Expand Down

0 comments on commit 49cf332

Please sign in to comment.