Re: Remove integer from float number
- From: Larry Bates <larry.bates@xxxxxxxxxxx>
- Date: Thu, 23 Mar 2006 15:31:06 -0600
John Machin wrote:
On 24/03/2006 6:44 AM, Larry Bates wrote:
Derek Basch wrote:
How can I return:
".666"
from float:
"0.666"
This is what I have so far:
"%.6f" % x
Thanks Everyone,
Derek Basch
This works but I'm not entirely sure I know what you are
trying to accomplish.
("%.3f" % x)[1:]
'2345.666'x = 12345.666; ("%.3f" % x)[1:]
I'm sure of neither what the OP is trying to accomplish nor what Larry's
definition of "works" is :-)
Perhaps the condition abs(x) < 1.0 is implied ...
For the example given, my code works. With so little information
the only thing I could do is answer the specific question and
caveat it that I don't know "exactly" what OP is trying to accomplish.
By the OPs response to my post, it was what he was looking for.
But I agree it is very much an edge-case question.
-Larry Bates
.
- Follow-Ups:
- Re: Remove integer from float number
- From: Arne Ludwig
- Re: Remove integer from float number
- References:
- Remove integer from float number
- From: Derek Basch
- Re: Remove integer from float number
- From: Larry Bates
- Re: Remove integer from float number
- From: John Machin
- Remove integer from float number
- Prev by Date: Re: boost python tutorial
- Next by Date: Re: removing file by inode
- Previous by thread: Re: Remove integer from float number
- Next by thread: Re: Remove integer from float number
- Index(es):
Relevant Pages
|