Skip to content

Commit

Permalink
Fixed big bug with float numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
MP3Martin committed Sep 12, 2022
1 parent 96b5dd9 commit 5a64150
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
41 changes: 34 additions & 7 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,44 @@ def copy_output():
clipboard(string)

def floatToIntForDivision(f1: string, f2: string):
f1 = str(float(f1))
f2 = str(float(f2))
if not str(f1).endswith(".0") and not str(f2).endswith(".0"):
#stringToStringFLoat
def stsf(string):
string = str(string)
if "." in string:
return "" + string
else:
return string + ".0"

def moveDotRight(arg_string):
string = stsf(arg_string)
if string.endswith(".0"):
string = string[:-2]
string = string + "0.0"
return string
pos = string.find(".")
pos += 1
string = string.replace(".", "")
string = string[:pos] + "." + string[pos:]
if string.endswith("."):
string += "0"
string = string.lstrip("0")
if string.startswith("."):
string = "0" + string
return string

f1_ = stsf(f1)
f2_ = stsf(f2)
# print([f1_, f2_])
if f1_.endswith(".0") == False or f2_.endswith(".0") == False:
# print("is not full number")
while True:
if str(f1).endswith(".0") and str(f2).endswith(".0"):
if str(f1_).endswith(".0") and str(f2_).endswith(".0"):
break
else:
f1 = str(float(f1) * 10)
f2 = str(float(f2) * 10)
f1_ = moveDotRight(f1_)
f2_ = moveDotRight(f2_)

return [str(int(float(f1))), str(int(float(f2)))]
return [f1_[:-2], f2_[:-2]]

def calculate():
global default_output_text
Expand Down
2 changes: 2 additions & 0 deletions real_division_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ def calc(one, two):
one = int(one)
two = int(two)

# print([one, two])

#Functions
def howManyTimesDoesItFit(one1: int, two1: int):
temp_one = one1
Expand Down

0 comments on commit 5a64150

Please sign in to comment.