Best way to calculate fraction part of x?
Jason Swails
jason.swails at gmail.com
Tue Mar 24 21:39:43 EDT 2015
On Mon, Mar 23, 2015 at 8:38 PM, Emile van Sebille <emile at 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...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150324/c9848dd7/attachment.html>
More information about the Python-list
mailing list