Maybe it´s a stupid statement, if it is forgive me, but here it goes: And if was there some kind of mask system, something similar to that in COBOL for example (yes, I know...but it was very practical) in the db model. Many db apps have this. In this case it could use regex or some something simpler. It would be useful to this issue and many others and I think it must not depend on db backend. This functionality should integrate (obviously) along the framework from the db model to the widgets and would enforce validation so much.
Am I talking bullshit? Let me know why! On Nov 14, 4:19 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > status report. > > 1) I reverted from 'repr' to 'str'. we are going to have rounding > errors with sqlite but not as big as in my example before. > > 2) I also have added support for decimal for all the other databases > that support it. There is an issue with some adapters so I do not > swear by this. Moreover I did not have time to check it carefully. > > I am caching a flight tomorrow morning so I will probably be unable to > look at this again for 24hrs. > > If you get a chance to test it please let me know. Just knowing that > you can get data in and out using any database other than sqlite would > be important. > > Mind that you cannot do: > > db.define_table('a',Field('b','decimal(10,3))) > db.a.insert(b=3.14) > > You have to do > > db.a.insert(b='3.14') > > Massimo > > P.S. if anybody from the list is going to be to SuperComputing Sunday- > Tuesday and want to meet for a coffee, send me an email. > > On Nov 14, 12:04 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > decimal is a big can of worms: > > >http://www.mail-archive.com/django-us...@googlegroups.com/msg89642.html > > > On Nov 13, 11:43 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > Fascinating. As an experiment I replaced str with repr and it usually > > > works with float. Float is better then integer because allows > > > migrations from one decimal type to float and vice versa and allows > > > for expressions involving different field types without major errors. > > > > The problem is that when it fails, it has major failures. > > > > Everybody should be aware that there will be much bigger rounding > > > errors with type='decimal' on sqlite than with type='double'. With > > > double the rounding errors will be of the order of required decimal > > > precision, much bigger than double precision. > > > > That is because is > > > > >>> a = 0.3/3 # is float > > > >>> print str(a)[0:5] > > > > 0.1 > > > > while > > > > >>> from decimal import Decimal > > > >>> b=Decimal(repr(a)[0:5]) > > > >>> print b > > > > 0.099 > > > > Conversions like the one above are necessary step to get data in/out > > > of database. > > > > The more I look into this the more I think we should not support it if > > > the database does not support it. > > > > Massimo > > > > On Nov 13, 9:27 pm, Jonathan Lundell <jlund...@pobox.com> wrote: > > > > > On Nov 13, 2009, at 4:36 PM, Massimo Di Pierro wrote: > > > > > > In theory double has 53 bits. Yet I tried and it does not seem to > > > > > work > > > > > properly. It rounds to the cents. You may want to try the attached > > > > > files. Perhaps I am doing something wrong. > > > > > I'm not advocating floating point; I think it's a pain, and if integer > > > > is working, that's better. But.... > > > > > >>> from decimal import * > > > > >>> b = Decimal("1234567891.987654321") > > > > >>> b > > > > > Decimal('1234567891.987654321')>>> float(b) > > > > 1234567891.9876542 > > > > >>> str(float(b)) > > > > '1234567891.99' > > > > >>> repr(float(b)) > > > > > '1234567891.9876542' > > > > > I haven't checked, but it looks like an artifact of float.str. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---