On 22.02.13 11:16, Steven D'Aprano wrote:
On Fri, 22 Feb 2013 08:23:27 +1100, Chris Angelico wrote:
and you can cast out 1's in binary to find out if it's a
multiple of 1, too.
O_o
I wanna see the numbers that aren't a multiple of 1.
What "to be a multiple of" means? If A is a multiple of B
On Thu, 21 Feb 2013 19:33:32 +, Schizoid Man wrote:
> Hi there,
>
> I run the following code in Python 3.3.0 (on a Windows 7 machine) and
> Python 2.7.3 on a Mac and I get two different results:
Others have already explained that math.pow and the ** exponentiation
operator are subtly differ
On Fri, 22 Feb 2013 08:23:27 +1100, Chris Angelico wrote:
> and you can cast out 1's in binary to find out if it's a
> multiple of 1, too.
O_o
I wanna see the numbers that aren't a multiple of 1.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On 02/21/2013 05:44 PM, Schizoid Man wrote:
No, I was aware to be honest. I thought ** was just short hand for
math.pow(). Since ** is the integer operation
It's an integer operation because you started with two ints. Unlike
math.pow, which converts to floats, whatever you feed it.
I
On Fri, Feb 22, 2013 at 9:44 AM, Schizoid Man wrote:
>
> No, I was aware to be honest. I thought ** was just short hand for
> math.pow(). Since ** is the integer operation, I suppose ^ doesn't work as
> an exponent function in Python?
^ is bitwise XOR, completely different.
ChrisA
--
http://mai
On Thu, Feb 21, 2013 at 4:41 PM, Schizoid Man wrote:
> So how is operator.pow() different from just pow()?
math.pow() is a wrapper around the C library function.
** and operator.pow() are the same thing; the latter is just a
function version of the former.
The built-in pow() is a mutant version
On 21 February 2013 23:41, Schizoid Man wrote:
> "Oscar Benjamin" wrote in
>> Then you want operator.pow:
>>
> import operator
> operator.pow(3, 2)
>>
>> 9
>>
>> math.pow is basically the (double)pow(double, double) function from
>> the underlying C library. operator.pow(a, b) is precisel
"Oscar Benjamin" wrote in
Then you want operator.pow:
import operator
operator.pow(3, 2)
9
math.pow is basically the (double)pow(double, double) function from
the underlying C library. operator.pow(a, b) is precisely the same as
a**b.
So how is operator.pow() different from just pow()?
"Dave Angel" wrote
One other test:
diff = set(map(int, result1)).symmetric_difference(set(result2))
if diff:
print diff
print len(diff)
shows me a diff set of 15656 members. One such member:
135525271560688054250931600108742713928222656250
On Fri, Feb 22, 2013 at 9:33 AM, Dave Angel wrote:
> On 02/21/2013 05:11 PM, Chris Angelico wrote:
>>
>>
>>>
>>
>>
>> Note how, in each case, calculating three powers that have the same
>> real-number result gives a one-element set. Three to the sixtieth
>> power can't be perfectly rendered with
On 21 February 2013 22:39, Schizoid Man wrote:
> "Dave Angel" wrote in message
>>
>> On 02/21/2013 02:33 PM, Schizoid Man wrote:
>> However, there is an important inaccuracy in math.pow, because it uses
>> floats to do the work. If you have very large integers, that means some of
>> them won't b
"Chris Angelico" wrote in
First, are you aware that ** will return int (or sometimes long on
2.7.3), while math.pow() will return a float? That may tell you why
you're seeing differences. That said, though, I wasn't able to
replicate your result using 2.7.3 and 3.3.0 both on Windows - always
"Dave Angel" wrote in message
On 02/21/2013 02:33 PM, Schizoid Man wrote:
However, there is an important inaccuracy in math.pow, because it uses
floats to do the work. If you have very large integers, that means some
of them won't be correct. The following are some examples for 2.7.3 on
L
On 02/21/2013 05:11 PM, Chris Angelico wrote:
Note how, in each case, calculating three powers that have the same
real-number result gives a one-element set. Three to the sixtieth
power can't be perfectly rendered with a 53-bit mantissa, but it's
rendered the same way whichever route is use
On Fri, Feb 22, 2013 at 8:59 AM, Peter Pearson wrote:
> On Fri, 22 Feb 2013 08:23:27 +1100, Chris Angelico wrote:
>> In theory, a float should hold the nearest representable value to the
>> exact result. Considering that only one operation is being performed,
>> there should be no accumulation of
On Fri, 22 Feb 2013 08:23:27 +1100, Chris Angelico wrote:
> On Fri, Feb 22, 2013 at 7:49 AM, Dave Angel wrote:
>> However, if I do:
>>
>> print 3**60, "\n", int(math.pow(3,60)), "\n", pow(3,60)
>>
>>
>> I get:
>>
>> 42391158275216203514294433201
>> 42391158275216203520420085760
>> 423911582752162
On Fri, Feb 22, 2013 at 7:49 AM, Dave Angel wrote:
> However, if I do:
>
> print 3**60, "\n", int(math.pow(3,60)), "\n", pow(3,60)
>
>
> I get:
>
> 42391158275216203514294433201
> 42391158275216203520420085760
> 42391158275216203514294433201
>
>
> and the middle one is the one that's wrong.
In th
On 02/21/2013 03:25 PM, Dave Angel wrote:
a b math.pow(a,b) a**b
3 34 1.66771816997e+16 16677181699666569
3 35 5.0031545099e+16 50031545098999707
...
5 23 1.19209289551e+16 11920928955078125
The built-in pow, on the other hand, seems to get identical answers for
all these
On Fri, Feb 22, 2013 at 6:33 AM, Schizoid Man wrote:
> Hi there,
>
> I run the following code in Python 3.3.0 (on a Windows 7 machine) and Python
> 2.7.3 on a Mac and I get two different results:
>
>result1.append(math.pow(a,b))
>result2.append(a**b)
First, are you aware that ** w
On Thu, Feb 21, 2013 at 12:33 PM, Schizoid Man
wrote:
> Hi there,
>
> I run the following code in Python 3.3.0 (on a Windows 7 machine) and Python
> 2.7.3 on a Mac and I get two different results:
>
> result1 = []
> result2 = []
> for a in range(2,101):
>for b in range(2,101):
>result1
On 02/21/2013 02:33 PM, Schizoid Man wrote:
Hi there,
I run the following code in Python 3.3.0 (on a Windows 7 machine) and
Python 2.7.3 on a Mac and I get two different results:
result1 = []
result2 = []
for a in range(2,101):
for b in range(2,101):
result1.append(math.pow(a,b))
Hi there,
I run the following code in Python 3.3.0 (on a Windows 7 machine) and Python
2.7.3 on a Mac and I get two different results:
result1 = []
result2 = []
for a in range(2,101):
for b in range(2,101):
result1.append(math.pow(a,b))
result2.append(a**b)
result1 = list(set(
22 matches
Mail list logo