Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'folks,': 0.09; 'received:209.85.216.53': 0.09; 'received:mail- qw0-f53.google.com': 0.09; 'subject:error': 0.09; 'float': 0.13; '(say': 0.16; 'from:addr:fetchinson': 0.16; 'from:name:daniel fetchinson': 0.16; 'function?': 0.16; 'parentheses': 0.16; 'psss,': 0.16; 'simplest': 0.16; 'subject:result': 0.16; 'url:putitdown': 0.16; 'arguments': 0.18; 'cheers,': 0.20; 'tells': 0.21; 'string': 0.24; 'function': 0.27; 'subject:" ': 0.28; 'message-id:@mail.gmail.com': 0.29; '(and': 0.30; 'subject:format': 0.30; "didn't": 0.30; 'error': 0.30; 'from:addr:googlemail.com': 0.31; "i've": 0.32; 'times.': 0.34; 'daniel': 0.34; 'done': 0.34; 'anything': 0.34; 'round': 0.34; 'to:addr:python-list': 0.35; 'something': 0.35; 'things': 0.35; 'digit': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'received:209': 0.39; 'put': 0.40; 'to:addr:python.org': 0.40; 'simple': 0.61; 'vary': 0.64; 'so:': 0.84; 'subject:its': 0.84; 'expresses': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=kOwSA0g2jfHE91E7FY7cuV4MtoLDNH59CThb2Jj0hYY=; b=HVUHXGgInITF6FTF/DATRjshSioAwLaIZnhfTt27RTC5k5053LCcrAxJSLzY8Jgni+ plM8qge52g6uWEartjE14bli6RZKRrilfK5PaY9H7oCnW/kijQSLUUZ1/RTMHvzMUqaw qCX3eZGkfnM/qCegjHjieY0qPdSd+ZE8r12es= MIME-Version: 1.0 Date: Thu, 16 Feb 2012 01:18:07 +0100 Subject: format a measurement result and its error in "scientific" way From: Daniel Fetchinson To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329351490 news.xs4all.nl 6959 [2001:888:2000:d::a6]:53347 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20493 Hi folks, often times in science one expresses a value (say 1.03789291) and its error (say 0.00089) in a short way by parentheses like so: 1.0379(9) One can vary things a bit, but let's take the simplest case when we only keep 1 digit of the error (and round it of course) and round the value correspondingly. I've been searching around for a simple function that would take 2 float arguments and would return a string but didn't find anything although something tells me it's been done a gazillion times. What would be the simplest such function? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown