[spambayes-dev] RE: RE: [Spambayes] Question (orpossibly a bug report)

Scott David Daniels Scott.Daniels at Acm.Org
Fri Jul 25 07:17:50 EDT 2003


I've been seeing a lot of "we'll have to use float(123)/100"
messages floating around, and I'd like to point out there is an
atof-able form for floating point numbers:
           256.7654e-7  =  2567654e-11

def safestr(floatstr):
     """Return a locale-safe version of C-locale-generated floatstr"""
     try:
	decpos = floatstr.index('.')
     except ValueError:
	return floatstr
     try:
	exppos = floatstr.lower().index('e')
     except ValueError:
	ebias = 0
	exppos = len(sv)
     else:
	ebias = int(floatstr[exppos+1:])
     return '%s%se%s' % (floatstr[:decpos], floatstr[decpos+1:exppos],
			ebias + 1 - exppos + decpos)


floating-point-need-not-use-fractional-mantissas-ly yours,
-Scott David Daniels





More information about the spambayes-dev mailing list