(self, n_before, n_decimals, force_dot, group_digits)
return self._scientific_notation(
            digitstr, exp10, digits_to_dot=n_before, force_dot=force_dot, group_digits=group_digits
        )
Put a float in scientific format.
Put a float in scientific format.
Put a float in scientific format .
def to_str_scientific(self, n_before, n_decimals, force_dot, group_digits):
        """Put a float in scientific format."""
        if self.is_zero():
            if force_dot:
                return b''.join((b'.', (b'0' * n_decimals), self.exp_sign, b'+00'))
            # single/double difference: this matches GW output. odd, odd, odd
            if self.exp_sign == b'E':
                return b'E+00'
            return b'0D+00'
        n_work = min(self.digits, n_before + n_decimals)
        # special case when work_digits == 0, see also below
        # setting to 0 results in incorrect rounding (why?)
        mantissa, exp10 = self.to_decimal(1 if n_work == 0 else n_work)
        digitstr = _get_digits(mantissa, n_work, remove_trailing=True)
        # append zeros if necessary
        digitstr = digitstr.ljust(n_decimals + n_before, b'0')
        # this is just to reproduce GW results for no digits:
        # e.g. PRINT USING "#^^^^";1 gives " E+01" not " E+00"
        if n_work == 0:
            exp10 += 1
        exp10 += n_before + n_decimals - 1
        return self._scientific_notation(
            digitstr, exp10, digits_to_dot=n_before, force_dot=force_dot, group_digits=group_digits
        )
def to_str_scientific ( self , n_before , n_decimals , force_dot , group_digits ) : if self . is_zero ( ) : if force_dot : return b'' . join ( ( b'.' , ( b'0' * n_decimals ) , self . exp_sign , b'+00' ) ) # single/double difference: this matches GW output. odd, odd, odd if self . exp_sign == b'E' : return b'E+00' return b'0D+00' n_work = min ( self . digits , n_before + n_decimals ) # special case when work_digits == 0, see also below # setting to 0 results in incorrect rounding (why?) mantissa , exp10 = self . to_decimal ( 1 if n_work == 0 else n_work ) digitstr = _get_digits ( mantissa , n_work , remove_trailing = True ) # append zeros if necessary digitstr = digitstr . ljust ( n_decimals + n_before , b'0' ) # this is just to reproduce GW results for no digits: # e.g. PRINT USING "#^^^^";1 gives " E+01" not " E+00" if n_work == 0 : exp10 += 1 exp10 += n_before + n_decimals - 1 return self . _scientific_notation ( digitstr , exp10 , digits_to_dot = n_before , force_dot = force_dot , group_digits = group_digits )