Skip to content

Commit

Permalink
Fixing bug when underscores appear on the rhs of the decimal (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
slundqui authored Nov 13, 2023
1 parent d6b43aa commit d8ebba7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/fixedpointmath/fixedpointmath/fixed_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ def _set_str(self, unscaled_value: str) -> None:

if "." not in mantissa: # input is always assumed to be a float
mantissa += ".0"
integer, remainder = mantissa.split(".")

# removes underscores; they won't affect `int` cast and will affect `len`
mantissa = mantissa.replace("_", "")

integer, remainder = mantissa.split(".")
is_negative = "-" in integer
if is_negative:
super().__setattr__(
Expand Down

0 comments on commit d8ebba7

Please sign in to comment.