Skip to content

Commit

Permalink
Autoformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoConti committed Nov 9, 2024
1 parent ae6199d commit 7a0f666
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Deeploy/AbstractDataTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ def checkValue(cls, value: Union[int, Iterable[int]], ctxt: Optional[_NetworkCon

class FloatImmediate(Immediate[Union[float, Iterable[float]], _ImmediateType]):
# FIXME: check typeFraction vs typeMantissa
typeFraction: int #: int: Represents the number of bits reserved for the fraction part
typeExponent: int #: int: Represents the number of bits reserved for the exponent part
typeFraction: int #: int: Represents the number of bits reserved for the fraction part
typeExponent: int #: int: Represents the number of bits reserved for the exponent part

@_classproperty
def typeExponentMax(cls) -> int:
Expand Down Expand Up @@ -285,7 +285,7 @@ def checkValue(cls, value: Union[float, Iterable[float]], ctxt: Optional[_Networ
# Also bring mantissa and exponent to IEEE754 compliant form for non-denormals.
mantissa, exponent = math.frexp(val)
sign = True if mantissa < 0 else False
mantissa = -mantissa*2 if sign else mantissa*2
mantissa = -mantissa * 2 if sign else mantissa * 2
exponent -= 1

# Check if the number is finite, nonzero and not denormal, otherwise skip the check.
Expand All @@ -295,9 +295,9 @@ def checkValue(cls, value: Union[float, Iterable[float]], ctxt: Optional[_Networ
# Check if exponent is representable.
if (cls.typeExponentOffset + exponent) > cls.typeExponentMax or (cls.typeExponentOffset + exponent) < 0:
return False

# Check if mantissa is representable. Implicit assumption is that cls.typeFraction < 52 (like in FP64)
truncated_mantissa = 1 + math.floor((2 ** cls.typeFraction) * (mantissa-1)) / (2 ** cls.typeFraction)
truncated_mantissa = 1 + math.floor((2**cls.typeFraction) * (mantissa - 1)) / (2**cls.typeFraction)
if math.fabs(truncated_mantissa - mantissa) > 0.0:
return False

Expand Down

0 comments on commit 7a0f666

Please sign in to comment.