I think you ought to make your own class and define some of the special
methods.
mt
--
http://mail.python.org/mailman/listinfo/python-list
kpp9c wrote:
> okay... out of curiousity... how would you then seperate the interger
> value from the fractional part do something to one side and then put it
> back together... like if you had 8.01 and you want to add to the '8'
> part in one way (ordinary decimal) and add to the .01 part modulo
>
Sorry about the Top Posting that I did before.
It is just the style I am used to using, and I didn't
realize that it was different here. I won't do it again.
--
http://mail.python.org/mailman/listinfo/python-list
okay... out of curiousity... how would you then seperate the interger
value from the fractional part do something to one side and then put it
back together... like if you had 8.01 and you want to add to the '8'
part in one way (ordinary decimal) and add to the .01 part modulo
something .. like say
"Michael Yanowitz" <[EMAIL PROTECTED]> writes:
> Sorry, got it backwards:
You also got the reply backwards (in both cases).
http://en.wikipedia.org/Top_posting>
--
\"No one ever went broke underestimating the taste of the |
`\American public." --
On 2006-03-23, Michael Yanowitz <[EMAIL PROTECTED]> wrote:
> Sorry, got it backwards:
> def printDecimal(number):
> if (number >= 0):
> print number - int(number)
> else:
> print int(number) - number
Still top posted and still doesn't work:
>>> def printDecimal(number):
.
On 2006-03-23, Michael Yanowitz <[EMAIL PROTECTED]> wrote:
>> With that terse description and the subject line I would interpret the
>> OP like so:
>>
> print re.sub(".*\.",".","0.666")
>> .666
> print re.sub(".*\.",".","123.666")
>> .666
>
> Or if you're allergic to regular expressions:
>
:21 PM
To: python-list@python.org
Subject: RE: Remove integer from float number
how about this solution:
def printDecimal(number):
if (number < 0):
print number - int(number)
else:
print int(number) - number
-Original Message-
From: [EMAIL PROTECTED]
[
:11 PM
To: python-list@python.org
Subject: Re: Remove integer from float number
On 2006-03-23, Arne Ludwig <[EMAIL PROTECTED]> wrote:
> With that terse description and the subject line I would interpret the
> OP like so:
>
>>>> print re.sub(".*\.&quo
On 2006-03-23, Arne Ludwig <[EMAIL PROTECTED]> wrote:
> With that terse description and the subject line I would interpret the
> OP like so:
>
print re.sub(".*\.",".","0.666")
> .666
print re.sub(".*\.",".","123.666")
> .666
Or if you're allergic to regular expressions:
>>> print "." +
With that terse description and the subject line I would interpret the
OP like so:
>>> print re.sub(".*\.",".","0.666")
.666
>>> print re.sub(".*\.",".","123.666")
.666
--
http://mail.python.org/mailman/listinfo/python-list
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
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
"Derek Basch" <[EMAIL PROTECTED]> writes:
> Ahh yes you have to put parenthases around the string formatting to
> remove the integer using indexes. Thanks, that's just what I needed!
I think it's better to remove leading zeros explicitly:
('%.3x' % x).lstrip('0')
--
http://mail.python.org/ma
Ahh yes you have to put parenthases around the string formatting to
remove the integer using indexes. Thanks, that's just what I needed!
Derek Basch
--
http://mail.python.org/mailman/listinfo/python-list
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:]
-Larry Bates
--
http://mai
How can I return:
".666"
from float:
"0.666"
This is what I have so far:
>>> "%.6f" % x
Thanks Everyone,
Derek Basch
--
http://mail.python.org/mailman/listinfo/python-list
17 matches
Mail list logo