(self, in_float)
return self
Set to value of Python float.
Set to value of Python float.
Set to value of Python float .
def from_value(self, in_float):
        """Set to value of Python float."""
        if in_float == 0.:
            self._buffer[:] = b'\0' * self.size
            return self
        neg = in_float < 0
        exp = int(math.log(abs(in_float), 2) - self._shift)
        man = int(abs(in_float) * 0.5**exp)
        exp += self._bias
        # why do we need this here?
        man, exp = self._bring_to_range(man, exp, self._posmask, self._mask)
        if not self._check_limits(exp, neg):
            return self
        struct.pack_into(
            self._intformat, self._buffer, 0, man & (self._mask if neg else self._posmask)
        )
        self._buffer[-1:] = int2byte(exp)
        return self
def from_value ( self , in_float ) : if in_float == 0. : self . _buffer [ : ] = b'\0' * self . size return self neg = in_float < 0 exp = int ( math . log ( abs ( in_float ) , 2 ) - self . _shift ) man = int ( abs ( in_float ) * 0.5 ** exp ) exp += self . _bias # why do we need this here? man , exp = self . _bring_to_range ( man , exp , self . _posmask , self . _mask ) if not self . _check_limits ( exp , neg ) : return self struct . pack_into ( self . _intformat , self . _buffer , 0 , man & ( self . _mask if neg else self . _posmask ) ) self . _buffer [ - 1 : ] = int2byte ( exp ) return self