Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Frank Millman" Newsgroups: comp.lang.python Subject: Re: Problem with sqlite3 and Decimal Date: Sat, 12 Dec 2015 07:10:14 +0200 Lines: 39 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de EgNo+QmBzRfi1/FUSbIrewazg0GzmmCAHK+Ifbllbwhw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'only,': 0.07; 'subject:sqlite3': 0.07; 'events.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'question.': 0.13; 'curious.': 0.16; 'oddity': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reproduce': 0.16; 'skip:n 70': 0.16; 'sqlite3': 0.16; 'subject:Problem': 0.16; 'wrote:': 0.16; 'result,': 0.18; 'string,': 0.18; '2015': 0.20; 'select': 0.23; 'seems': 0.23; 'wrote': 0.23; 'academic': 0.23; 'dec': 0.23; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'header:X -Complaints-To:1': 0.26; 'fri,': 0.27; 'right.': 0.27; 'issue,': 0.27; 'sequence': 0.27; 'idea': 0.28; 'initial': 0.28; 'arithmetic': 0.29; 'noticed': 0.32; 'asking': 0.35; 'but': 0.36; 'tool': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'skip:5 10': 0.37; 'thought': 0.37; 'goes': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'still': 0.40; 'your': 0.60; 'interest': 0.64; 'here': 0.66; 'frank': 0.72; 'bal': 0.84; 'why?': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 197.82.211.31 In-Reply-To: X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 15.4.3502.922 X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3502.922 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100317 "Chris Angelico" wrote in message news:CAPTjJmor6NewucCo7XTSSwyyfbgwCWZ8Jt-MjjkYSjOCFu78_A@mail.gmail.com... On Fri, Dec 11, 2015 at 8:21 PM, Frank Millman wrote: > > I noticed one oddity - I am asking sqlite3 to store the value as a > > string, > > but then I am asking it to perform arithmetic on it. > It's an SQLite3 issue, not a Python one. I used the sqlite3 > stand-alone tool to do the same thing: > sqlite> update fmtemp set bal = bal + cast('123.45' as numeric); > sqlite> select bal from fmtemp; > ... > 5678.7 > 5802.15 > 5925.59999999999 > You are right. I am still investigating alternatives, and will report back, but here is a quick question. I can reproduce your example above. However, if I set the initial value to 5678.7, then the sequence goes 5678.7 5802.15 5925.6 6049.05 6172.5 I would have thought that adding 123.45 to 5802.15 would always produce the same result, but here it seems to depend on prior events. Any idea why? Academic interest only, but I am curious. Frank