Skip to content

Commit

Permalink
Fix another scaling error
Browse files Browse the repository at this point in the history
Signed-off-by: Chipmuenk <[email protected]>
  • Loading branch information
chipmuenk committed May 16, 2017
1 parent 20ef942 commit f7b5e5b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pyfda/pyfda_fix_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,16 +652,16 @@ def frmt2float(self, y, frmt=None):
elif frmt in {'hex', 'bin'}:
try:
y_int = int(raw_str, self.base)
# two's complement formatsneed to be treated separately:
if frmt in {'bin', 'hex'} and y_int >= self.MSB:
y_int = y_int - 2 * self.MSB
# two's complement formats need to be treated separately
if frmt in {'bin', 'hex'} and y_int >= (1 << (self.W-1)):
y_int = y_int - (1 << self.W)
# quantize / saturate / wrap the integer value:
if self.point:
y_fix = self.fix(y_int * self.LSB)
y_float = self.fix(y_int * self.LSB) * self.LSB
else:
y_fix = self.fix(y_int, from_float = False)
y_float = self.fix(y_int, from_float = False) / self.MSB
# scale integer fixpoint value
y_float = y_fix / 2**(self.W-1)
#y_float = y_fix / self.MSB#2**(self.W-1)

except Exception as e:
logger.warn(e)
Expand Down

0 comments on commit f7b5e5b

Please sign in to comment.