[Tutor] Money matters
I am going to need to be handling money calculations and was wondering about the float problem in my calculations. Should I simply run the results of all calculations through something like this: from __future__ import division ... ... s=(int(round(s, 2)*100))/100 Or should I be using Decimal on all money calculations? Or, is there another more preferred approach? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Money matters
Terry said unto the world upon 06/28/2007 02:55 PM: I am going to need to be handling money calculations and was wondering about the float problem in my calculations. Should I simply run the results of all calculations through something like this: from __future__ import division ... ... s=(int(round(s, 2)*100))/100 Or should I be using Decimal on all money calculations? Or, is there another more preferred approach? Hi Terry, I'd say definitely use Decimal. Money calculations were a primary use case for the Decimal module. (Though a bit more needs to be done to get the right decimal precision. See http://www.python.org/dev/peps/pep-0327/.) Best, Brian vdB ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Money matters
Should I simply run the results of all calculations through something like this: from __future__ import division ... ... s=(int(round(s, 2)*100))/100 Or should I be using Decimal on all money calculations? Firstly - that does not magically fix the imprecisions in floating point numbers. If that would work, it would be hardcoded into the interpreter, no? I think that Decimal is the way to go here, but you do have another option. Whenever you put in a number, remove the decimal point and store it as an integer. Do all of you calculations with integers. Every time you have to display a total, convert it then (but don't overwrite the variable! Convert a temp) Obviously this is a tough way to go in an easy language like python. That is a solution I am considering using C. (I might just make it too..) That's why I encouraged Decimal. If you're interested in the integer representation of floats, like this particular efficiency precision demon (me!), then you will have to work out ways to multiply and divide using pseudo floats... Not too difficult. Say you want to multiply an integer against say 5.5 %. Multiply the total by ten, 55, then divide by a 100. In that order. Of course you will still have problems. For example do it over and over and you will overflow your integer, but nevermind. Am I rambling? Ooops. HTH, tiger12506 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Money matters
Thanks! I am playing with Decimal suggested recipe now and it is just way cool! Perfect! In fact, more than perfect! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] MONEY MATTERS
ok, SHOULD THIS BE A THREAD OR A SEPERATE LIST? Many of ius are independants, and write code for the love of it- or to promote and sell independantly. So possibly a thread discussing ways to turn useful code into moiney is a useful idea. If the wish of the list is a thread here, we can do that, or we can start a seperate list for it. What are the wishes of this list? i don't think this is the right forum for such a thread. the main Python thread may be a better place, but i'd better *DUCK* before someone from other there throws anything at me. :-) this list is really meant for those who are either new to programming or new to Python, or both, to ask questions and get answers. perhaps an even *better* place would be to place this on your blog, and let respondents take the thread in any direction, yet have it be archived for all to read. cheers, -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Core Python Programming, Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] MONEY MATTERS
My 2 cents worth is to set up something separate, it'll just keep the principles and ideas clearer. While I have my own ideas about the million dollar application, I would like a forum where I can just listen and learn any type of ideas without having a worry that someone will 'steal' my idea and beat me to the market. I work for a state government supporting a SAP HR application, so anything I learn from this list is not directly applicable to my job. However, the ideas and logic to solve various PYTHON solutions is a big benefit in expanding my search for alternative solutions. And one day, I will have free time to work on my million dollar app. (LOL!) Thanks, Steve Oldner -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kirk Bailey Sent: Wednesday, March 21, 2007 10:14 PM To: tutor@python.org Subject: [Tutor] MONEY MATTERS ok, SHOULD THIS BE A THREAD OR A SEPERATE LIST? Many of ius are independants, and write code for the love of it- or to promote and sell independantly. So possibly a thread discussing ways to turn useful code into moiney is a useful idea. If the wish of the list is a thread here, we can do that, or we can start a seperate list for it. What are the wishes of this list? -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] MONEY MATTERS
Kirk Bailey wrote: ok, SHOULD THIS BE A THREAD OR A SEPERATE LIST? Many of ius are independants, and write code for the love of it- or to promote and sell independantly. So possibly a thread discussing ways to turn useful code into moiney is a useful idea. If the wish of the list is a thread here, we can do that, or we can start a seperate list for it. What are the wishes of this list? That is definitely not appropriate for this list. This list has a very clear purpose which is to provide a place for people to ask and answer beginner questions about Python. My guess is that there are already lists or web sites devoted to your idea, have you looked? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] MONEY MATTERS
So be it. The list now exists, and is called Coding4Cash. Here is a weblink to it: http://tech.groups.yahoo.com/group/coding4cash/ And here are email address': Post message: [EMAIL PROTECTED] Subscribe: [EMAIL PROTECTED] Unsubscribe:[EMAIL PROTECTED] List owner: [EMAIL PROTECTED] SPAM need not apply. Hackers, hobbyists, pros, guru's and them what know better but do it anyway for the hell of it are all welcome. This thread is ended in peace and respect; let all who wish come forth to discuss scratching the itch that our wallet does not yet contain. Steve Oldner wrote: My 2 cents worth is to set up something separate, it'll just keep the principles and ideas clearer. While I have my own ideas about the million dollar application, I would like a forum where I can just listen and learn any type of ideas without having a worry that someone will 'steal' my idea and beat me to the market. I work for a state government supporting a SAP HR application, so anything I learn from this list is not directly applicable to my job. However, the ideas and logic to solve various PYTHON solutions is a big benefit in expanding my search for alternative solutions. And one day, I will have free time to work on my million dollar app. (LOL!) Thanks, Steve Oldner -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kirk Bailey Sent: Wednesday, March 21, 2007 10:14 PM To: tutor@python.org Subject: [Tutor] MONEY MATTERS ok, SHOULD THIS BE A THREAD OR A SEPERATE LIST? Many of ius are independants, and write code for the love of it- or to promote and sell independantly. So possibly a thread discussing ways to turn useful code into moiney is a useful idea. If the wish of the list is a thread here, we can do that, or we can start a seperate list for it. What are the wishes of this list? -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Money Matters
Hello! I read this list because I'm new to Python and I really am learning an average of something new I did not know from every digest hitting my inbox. I have no interest on the matter of money. Just my .02$. -Omer Tabach [EMAIL PROTECTED] wrote: Message: 3 Date: Wed, 21 Mar 2007 23:13:57 -0400 From: Kirk Bailey Subject: [Tutor] MONEY MATTERS To: tutor@python.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1; format=flowed ok, SHOULD THIS BE A THREAD OR A SEPERATE LIST? Many of ius are independants, and write code for the love of it- or to promote and sell independantly. So possibly a thread discussing ways to turn useful code into moiney is a useful idea. If the wish of the list is a thread here, we can do that, or we can start a seperate list for it. What are the wishes of this list? -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. - Don't pick lemons. See all the new 2007 cars at Yahoo! Autos.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] MONEY MATTERS
ok, SHOULD THIS BE A THREAD OR A SEPERATE LIST? Many of ius are independants, and write code for the love of it- or to promote and sell independantly. So possibly a thread discussing ways to turn useful code into moiney is a useful idea. If the wish of the list is a thread here, we can do that, or we can start a seperate list for it. What are the wishes of this list? -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor