import math
math.pow(345643 23, 456356)
will give math range error.
how can i force python to process huge integers without math range
error? Any modules i can use possibly? 8 6850
fl1p-fl0p wrote: import math math.pow(345643 23, 456356)
will give math range error.
how can i force python to process huge integers without math range error? Any modules i can use possibly?
You have to use operator **, i.e. 34564323**45635 6
Em Dom, 2006-06-11 Ã*s 11:19 -0700, fl1p-fl0p escreveu: import math math.pow(345643 23, 456356)
will give math range error.
how can i force python to process huge integers without math range error? Any modules i can use possibly?
34564323**45635 6 ?
--
Felipe.
Wojciech Muła wrote: fl1p-fl0p wrote:
import math math.pow(345643 23, 456356)
will give math range error.
how can i force python to process huge integers without math range error? Any modules i can use possibly?
You have to use operator **, i.e. 34564323**45635 6
That's not very practical. That computation will produce a value with
more than 3.4 million digits. (That is, log10(34564323) *456356 =
3440298.) Python will attempt this, but I was not patient enough to see
if it could calculate an answer today (or even this week).
I doubt that you really *want* all 3.4 million digits. So what is it you
really want? A scientific or engineering result as a floating point
number accurate to some reasonable number of digits? That integer value
modulo some other integer (as used in various cryptology schemes)?
Gary Herron
Felipe Almeida Lessa wrote: Em Dom, 2006-06-11 Ã*s 11:19 -0700, fl1p-fl0p escreveu: import math math.pow(345643 23, 456356)
will give math range error.
how can i force python to process huge integers without math range error? Any modules i can use possibly?
34564323**45635 6 ?
I just tried this and it is taking an extremely long time even on a fast
machine with 4 Gb of RAM. Killed it after a couple of minutes. This
sort of calculation can be done with extended precision floating point
(as long as you don't need an exact answer). For example (using
defaults on a 64-bit machine), from clnum import mpf mpf(34564323)** 456356
mpf('1.39518106 833639480699862 472257296396643 e3440298',36)
compute time is about 160 microseconds.
For more information see http://calcrpnpy.sourceforge.net/clnumManual.html
For calculations involving large powers, you may still be better off
using logarithms.
Raymond L. Buvel wrote: I just tried this and it is taking an extremely long time even on a fast machine with 4 Gb of RAM. Killed it after a couple of minutes.
Thats odd.
34564323**45635 6 completed on my laptop in 28 seconds.
[Python 2.4.3, Celeron-M 1.3GHz, WinXP], and max memory consumption
during the whole process was about 11megs.
What python version are you using?
Regards
Sreeram
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEjHMhrgn 0plK5qqURApduAK C5GygYWWtQYTvEy ljR9nxW9n+rpACd F2qn
vk5u0zzWoRnfLLk iangJd90=
=zh3g
-----END PGP SIGNATURE-----
Raymond L. Buvel wrote: I just tried this and it is taking an extremely long time even on a fast machine with 4 Gb of RAM. Killed it after a couple of minutes.
You probably tried printing the value.
a = 34564323**45635 6 (takes just 28 seconds)
whereas
b = str(a) takes forever!
Regards
Sreeram
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEjHWxrgn 0plK5qqURAiJGAJ 9XYzqDi93YahIvV xqeCs/Ex9ikIQCgnSwu
Eq0mIHCk8o3nvWO llFFXDag=
=BFDh
-----END PGP SIGNATURE-----
K.S.Sreeram wrote: Raymond L. Buvel wrote: I just tried this and it is taking an extremely long time even on a fast machine with 4 Gb of RAM. Killed it after a couple of minutes.
Thats odd. 34564323**45635 6 completed on my laptop in 28 seconds. [Python 2.4.3, Celeron-M 1.3GHz, WinXP], and max memory consumption during the whole process was about 11megs.
What python version are you using?
Regards Sreeram
Sorry, I tripped over the display problem that Tim Peters has repeatedly
explained on this news group (decimal algorithm is quadratic in the
number of digits) :-(
On a 64-bit 2.2 GHz Opteron running Debian stable, Python 2.3 took 26
seconds and Python 2.4 took 11 seconds.
K.S.Sreeram wrote: Raymond L. Buvel wrote: I just tried this and it is taking an extremely long time even on a fast machine with 4 Gb of RAM. Killed it after a couple of minutes.
You probably tried printing the value.
a = 34564323**45635 6 (takes just 28 seconds) whereas b = str(a) takes forever!
Regards Sreeram
If you really want all 3,440,299 digits, use the DecInt module.. http://home.comcast.net/~casevh/
Using Python 2.4.3 on a 1.4Ghz Celeron, a=DecInt(345643 23) ** 456356
takes 20 seconds. astr=str(a) takes just over 1 second.
With DecInt and GMPY, the running times are 6.9 seconds and 0.4 seconds
respectively.
casevh This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Clueless Moron |
last post by:
Why do they act differently with respect to complex numbers?
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> pow(2, 0+1j)
(0.76923890136397211+0.63896127631363475j)
>>>
>>> import math
>>> math.pow(2, 0+1j)
|
by: limelight |
last post by:
I have discovered a math error in the .NET framework's Log function. It
returns incorrect results for varying powers of 2 that depend on whether the
program is run from within the IDE or from the command line. The amount by
which the calculation is off is very small; even though the double data type
holds the errant value, it seems to round off when printed (via ToString())
and shows the correct one. The problem is that the errant value is...
|
by: Tony |
last post by:
Using Math.pow(10000000,10) or Math.pow(10000*1000,10) returns:
9.999999999999999e+69 (Mozilla 0.8)
1e+70 (Opera 8 & Explorer 6)
Is this a Mozilla bug? Ten million is a power of ten, isn't it?
|
by: David |
last post by:
Here is some code. I am trying to figure out how to raise, say, x to
the yth power. I know that isn't explicitly what is in the code but
that is the idea I am trying to solve. See the 2nd for loop>>3 errors.
#include <stdio.h>
#include <math.h>
int main(void)
{
#define p 100000;
|
by: Darius Fatakia |
last post by:
Hi,
I seem to be having trouble with some of my math functions (pow, sqrt,
acos). They're the only ones I use in my code and they prevent the program
from compiling. I get a "undefined reference to 'pow'" error. Here is the
relevant portion of my code.
Your help would be appreciated. Thanks!
* Genetic Algorithm module
| |
by: a.dheeraj.kumar |
last post by:
i know that there is a function to find the logarithm of a number, sin,
cos, tan etc. but are there which can find sin^-1, cos^-1, tan^-1 and
antilog of a given number?
PS: sin^-1 means sin inverse. eg:
if sin 30 =1/2
30=sin inverse of 1/2
HELP!
|
by: Andy |
last post by:
Hi,
I noticed when migrating a 2002 application to 2003 that the system changed
to a different usage for pow(2,-15).
In 2002, it used double pow(double,double).
In 2003, it is using double pow(int,int).
You may note that pow(2,-15) and pow(2.0,-15.0) give different results.
math.h is included.
Is there some way to force studio to not use the complex prototypes?
math.h is the only include file being used. Why is it even linking to the...
|
by: Nondisclosure007 |
last post by:
Hello. If this is the wrong group for this, please let me know.
I'll
post it somewhere else.
I've been doing data imports into MS Excel (ver 2007) and using the
CORREL function. What I was wondering was is there anything like
this
in Visual Basic or C#? Or even a DLL? I've got VS2008 and I really
don't want to code the CORREL function by hand if I can just pass off
2 or more array's to a function that already exists.
|
by: Tzury Bar Yochay |
last post by:
What is the reason math.pow yields OverflowError while python itself
can
calculate these large numbers. e.g:
1e+308
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: math range error
10000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000
|
by: Lenni |
last post by:
Hi,
I'm currently writing a web application for bicycle wheel builders
that calculate the spoke length for all sorts of variations of hubs
and rims.
I have translated the formula from an Excel spreadsheet and in
JavaScript it looks like this:
var sll=Math.sqrt(Math.pow(((fdl/2*Math.sin((2*Math.PI*cross)))/
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |