comparison roundup/hyperdb.py @ 5175:e1e40674a0bc

Implement double-precision Number .. as an option to the 'Number' property.
author Ralf Schlatterbeck <rsc@runtux.com>
date Mon, 12 Dec 2016 13:53:47 +0100
parents 7b74a5addfea
children 462b0f76fce8 882dfa723df5
comparison
equal deleted inserted replaced
5174:a76fbb9f5535 5175:e1e40674a0bc
291 value = value.lower() in ('checked', 'yes', 'true', 'on', '1') 291 value = value.lower() in ('checked', 'yes', 'true', 'on', '1')
292 return value 292 return value
293 293
294 class Number(_Type): 294 class Number(_Type):
295 """An object designating a numeric property""" 295 """An object designating a numeric property"""
296 def __init__(self, use_double = False, **kw):
297 """ The value use_double tells the database backend to use a
298 floating-point format with more precision than the default.
299 Usually implemented by type 'double precision' in the sql
300 backend. The default is to use single-precision float (aka
301 'real') in the db. Note that sqlite already uses 8-byte for
302 floating point numbers.
303 """
304 self.use_double = use_double
305 _Type.__init__ (self, **kw)
306 super(Number, self).__init__(**kw)
296 def from_raw(self, value, **kw): 307 def from_raw(self, value, **kw):
297 value = value.strip() 308 value = value.strip()
298 try: 309 try:
299 value = float(value) 310 value = float(value)
300 except ValueError: 311 except ValueError:

Roundup Issue Tracker: http://roundup-tracker.org/