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
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
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
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
"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
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:
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
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
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
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
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
11 matches
Mail list logo