Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87916

Re: Best way to calculate fraction part of x?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jason.swails@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.058
X-Spam-Evidence '*H*': 0.89; '*S*': 0.01; 'float': 0.07; 'cc:addr :python-list': 0.11; '23,': 0.16; 'cc:name:python list': 0.16; 'number?': 0.16; 'other,': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'possibly': 0.26; 'van': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'pm,': 0.38; 'mar': 0.68; 'lose': 0.68; '2015': 0.84; 'subject:Best': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=wX5TU/WG7l/K63sLuaSUdhdmYhvtd5DNsR34xBE2VWg=; b=ZORuSzZfJ4LNBsSqbC4P7PiBx2yKGgyRqkn+ZNwts60BVzcq4Qoy82UuD8xEkvTuzQ a+YTRIXR3oc4iQO4sE7yymvc7Al5o4b0+2CN3e74S4sZ27HMDa94EYdingzUKPiSpGcT 1Q/B1hXoMsy5WbRyb/x9UhtQHpV7dHbKWJ6hRKd2u8aV1kkJPSFUD2C4M4tZ6ck9696g EVtsOQ0M+cAIDwPs470/yv9JrYKYguhiw+WJbtdnFbrDvCbhBjuIhVEGhNoRA5Bve9Kt 7BbowosIrFNt8B0MA/8S1zfzi/phz52LhJwAHjVJtqGLLoEUDeitd7JgoGZJxGlTc6sU 5ziQ==
MIME-Version 1.0
X-Received by 10.170.221.193 with SMTP id n184mr8585324ykf.69.1427247583104; Tue, 24 Mar 2015 18:39:43 -0700 (PDT)
In-Reply-To <meqbmo$4rb$1@ger.gmane.org>
References <55100c7a$0$13004$c3e8da3$5496439d@news.astraweb.com> <meqbmo$4rb$1@ger.gmane.org>
Date Tue, 24 Mar 2015 21:39:43 -0400
Subject Re: Best way to calculate fraction part of x?
From Jason Swails <jason.swails@gmail.com>
Cc python list <python-list@python.org>
Content-Type multipart/alternative; boundary=001a113a668e329471051212f939
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.125.1427247586.10327.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1427247586 news.xs4all.nl 2841 [2001:888:2000:d::a6]:60711
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87916

Show key headers only | View raw


[Multipart message β€” attachments visible in raw view] - view raw

On Mon, Mar 23, 2015 at 8:38 PM, Emile van Sebille <emile@fenx.com> wrote:

> On 3/23/2015 5:52 AM, Steven D'Aprano wrote:
>
>  Are there any other, possibly better, ways to calculate the fractional
>> part
>> of a number?
>>
>
> float (("%6.3f" % x)[-4:])


​In general you lose a lot of precision this way...​

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Best way to calculate fraction part of x? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-23 23:52 +1100
  Re: Best way to calculate fraction part of x? Skip Montanaro <skip.montanaro@gmail.com> - 2015-03-23 08:02 -0500
  Re: Best way to calculate fraction part of x? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-23 13:11 +0000
  Re: Best way to calculate fraction part of x? wxjmfauth@gmail.com - 2015-03-23 06:17 -0700
  Re: Best way to calculate fraction part of x? Emile van Sebille <emile@fenx.com> - 2015-03-23 17:38 -0700
  Re: Best way to calculate fraction part of x? Jason Swails <jason.swails@gmail.com> - 2015-03-24 21:39 -0400
  Re: Best way to calculate fraction part of x? Emile van Sebille <emile@fenx.com> - 2015-03-26 13:48 -0700
  Re: Best way to calculate fraction part of x? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-03-26 21:59 +0000
  Re: Best way to calculate fraction part of x? Russell Owen <rowen@uw.edu> - 2015-03-26 15:02 -0700

csiph-web