Re: Remove integer from float number

2006-03-24 Thread Michael Tobis
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

Re: Remove integer from float number

2006-03-24 Thread Peter Hansen
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 >

RE: Remove integer from float number

2006-03-24 Thread Michael Yanowitz
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

Re: Remove integer from float number

2006-03-23 Thread kpp9c
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

Re: Remove integer from float number

2006-03-23 Thread Ben Finney
"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." --

Re: Remove integer from float number

2006-03-23 Thread Grant Edwards
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): .

Re: Remove integer from float number

2006-03-23 Thread Grant Edwards
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: >

RE: Remove integer from float number

2006-03-23 Thread Michael Yanowitz
: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] [

RE: Remove integer from float number

2006-03-23 Thread Michael Yanowitz
: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

Re: Remove integer from float number

2006-03-23 Thread Grant Edwards
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 "." +

Re: Remove integer from float number

2006-03-23 Thread Arne Ludwig
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

Re: Remove integer from float number

2006-03-23 Thread Larry Bates
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

Re: Remove integer from float number

2006-03-23 Thread John Machin
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

Re: Remove integer from float number

2006-03-23 Thread Paul Rubin
"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

Re: Remove integer from float number

2006-03-23 Thread Derek Basch
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

Re: Remove integer from float number

2006-03-23 Thread Larry Bates
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

Remove integer from float number

2006-03-23 Thread Derek Basch
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