Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions evfs/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
accuracy_score,
)

from decimal import Decimal




def bin_to_real(bits, lower_limit, upper_limit, num):
Expand Down Expand Up @@ -58,11 +61,11 @@ def bin_to_real(bits, lower_limit, upper_limit, num):
"""

up = upper_limit - lower_limit

down = 2 ** len(bits) - 1

return lower_limit + ((up / down) * num)

#return lower_limit + ((up / down) * num)
return float(Decimal(lower_limit) + (Decimal((up / down)) * Decimal(num)))

def masktodecimal(upper_limit, lower_limit, num, k):

Expand Down Expand Up @@ -99,7 +102,7 @@ def masktodecimal(upper_limit, lower_limit, num, k):

"""

up = (num - lower_limit) * (2 ** k - 1)
up = float(Decimal(num - lower_limit) * Decimal(2 ** k - 1))

down = upper_limit - lower_limit

Expand Down