Converts a string into a float or decimal value.
( self, s, sign='+' )
| 3151 | return f |
| 3152 | |
| 3153 | def make_float( self, s, sign='+' ): |
| 3154 | """Converts a string into a float or decimal value.""" |
| 3155 | if decimal and self.float_type == NUMBER_DECIMAL: |
| 3156 | return self.make_decimal( s, sign ) |
| 3157 | |
| 3158 | if s.startswith('-') or s.startswith('+'): |
| 3159 | sign = s[0] |
| 3160 | s = s[1:] |
| 3161 | elif isinstance(sign, (int,long)): |
| 3162 | if sign < 0: |
| 3163 | sign = '-' |
| 3164 | else: |
| 3165 | sign = '+' |
| 3166 | |
| 3167 | try: |
| 3168 | f = float(s) |
| 3169 | except ValueError: |
| 3170 | f = nan |
| 3171 | else: |
| 3172 | if sign=='-': |
| 3173 | f *= -1 |
| 3174 | return f |
| 3175 | |
| 3176 | @property |
| 3177 | def leading_zero_radix(self): |
no test coverage detected