Re: Getting fractional part from a float without using string operations

2008-11-20 Thread James Harris
On 20 Nov, 06:01, srinivasan srinivas <[EMAIL PROTECTED]> wrote: > Yes it works for most of the cases. But it doesn't for the following case: > > >>> str(abs(int(1234567.89)-1234567.89)) > > '0.88999898' Well, that is 0.89 or about as near to it as the calculation can represent. Like other nu

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread Chris Rebert
TED]> > To: srinivasan srinivas <[EMAIL PROTECTED]> > Cc: Jeremiah Dodds <[EMAIL PROTECTED]>; python-list@python.org > Sent: Wednesday, 19 November, 2008 7:33:46 PM > Subject: Re: Getting fractional part from a float without using string > operations > > sriniva

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread srinivasan srinivas
CTED]> Cc: Jeremiah Dodds <[EMAIL PROTECTED]>; python-list@python.org Sent: Wednesday, 19 November, 2008 7:33:46 PM Subject: Re: Getting fractional part from a float without using string operations srinivasan srinivas wrote: > Yes. But it didn't give only the expected decima

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread John Machin
On Nov 20, 3:38 am, "Blind Anagram" <[EMAIL PROTECTED]> wrote: > "MRAB" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > On Nov 19, 1:44 pm, John Machin <[EMAIL PROTECTED]> wrote: > > > On Nov 20, 12:35 am, srinivasan srinivas <[EMAIL PROTECTED]> > > wrote: > > > > > | >>> import

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread Blind Anagram
"MRAB" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Nov 19, 1:44 pm, John Machin <[EMAIL PROTECTED]> wrote: On Nov 20, 12:35 am, srinivasan srinivas <[EMAIL PROTECTED]> wrote: | >>> import math | >>> num = 123.4567 | >>> math.modf(num) | (0.456699789, 123.0) def fra

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread Tino Wildenhain
srinivasan srinivas wrote: Yes. But it didn't give only the expected decimals. For ex: >>> a = 1.23 >>> abs(int(a) -a) 0.22998 I would like to get the result '0.23' only. well, thats what get stored internally - there is no way around it if you are using floating point numbers:

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread MRAB
On Nov 19, 1:44 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Nov 20, 12:35 am, srinivasan srinivas <[EMAIL PROTECTED]> > wrote: > > > | >>> import math > | >>> num = 123.4567 > | >>> math.modf(num) > | (0.456699789, 123.0) def frac(n): return n - int(n) -- http://mail.python.org/ma

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread srinivasan srinivas
hon-list@python.org Sent: Wednesday, 19 November, 2008 7:14:17 PM Subject: Re: Getting fractional part from a float without using string operations On Wed, Nov 19, 2008 at 8:35 AM, srinivasan srinivas <[EMAIL PROTECTED]> wrote: Thanks, Srini      Add more friends to your messenger and en

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread John Machin
On Nov 20, 12:35 am, srinivasan srinivas <[EMAIL PROTECTED]> wrote: | >>> import math | >>> num = 123.4567 | >>> math.modf(num) | (0.456699789, 123.0) -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread Jeremiah Dodds
On Wed, Nov 19, 2008 at 8:35 AM, srinivasan srinivas < [EMAIL PROTECTED]> wrote: > Thanks, > Srini > > > Add more friends to your messenger and enjoy! Go to > http://messenger.yahoo.com/invite/ > -- > http://mail.python.org/mailman/listinfo/python-list > x = 2.99340584 y = abs(int(x) - x) y

Getting fractional part from a float without using string operations

2008-11-19 Thread srinivasan srinivas
Thanks, Srini Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Time Complexity of String Operations

2008-07-22 Thread youtoo
On 22 jul, 01:39, "David Wahler" <[EMAIL PROTECTED]> wrote: > On Mon, Jul 21, 2008 at 10:31 PM, youtoo <[EMAIL PROTECTED]> wrote: > > It has been extensively discussed the time complexity (quadratic) of > > string concatenation (due to string's immutability). > > Actually, it is roughly linear, at

Re: Time Complexity of String Operations

2008-07-21 Thread Terry Reedy
youtoo wrote: It has been extensively discussed the time complexity (quadratic) of string concatenation (due to string's immutability). But what is: == the time complexity of string indexing? Is it constant? == the time complexity of string slicing? Is it O(K) with K the slice's length? How a

Re: Time Complexity of String Operations

2008-07-21 Thread David Wahler
On Mon, Jul 21, 2008 at 10:31 PM, youtoo <[EMAIL PROTECTED]> wrote: > It has been extensively discussed the time complexity (quadratic) of > string concatenation (due to string's immutability). Actually, it is roughly linear, at least for reasonable string lengths: $ python -V Python 2.5.2 $ pyth

Time Complexity of String Operations

2008-07-21 Thread youtoo
It has been extensively discussed the time complexity (quadratic) of string concatenation (due to string's immutability). But what is: == the time complexity of string indexing? Is it constant? == the time complexity of string slicing? Is it O(K) with K the slice's length? How are strings stored

Re: String operations

2004-12-10 Thread Terry Hancock
On Wednesday 01 December 2004 04:20 pm, Anoop Rajendra wrote: > os.execvp("condor_q",["condor_q","-l","-constraint",'"ProjectId==\\\"anoopr_samadams.fnal.gov_161903_30209\\\""']) > > doesnt work. Its definately a problem with one of the million > backslashes and quotes present, but I'm not able to

Re: String operations

2004-12-01 Thread Steve Holden
Anoop Rajendra wrote: Hi. I'm trying to resolve an issue with strings. The command(inclusive of the back-slashes) condor_q -l -constraint "ProjectId==\"anoopr_samadams.fnal.gov_161903_30209\"" is the only way the command returns the right result. I'm trying to run this command from inside a python

String operations

2004-12-01 Thread Anoop Rajendra
Hi. I'm trying to resolve an issue with strings. The command(inclusive of the back-slashes) condor_q -l -constraint "ProjectId==\"anoopr_samadams.fnal.gov_161903_30209\"" is the only way the command returns the right result. I'm trying to run this command from inside a python program. The way I