Advice on math modules or functions for very long numbers

2006-01-01 Thread rv457
Following is a very simple program.  I am trying to take the 9th root of a 
number (m), display it, and then recalculate it using the root value that was 
displayed.

As can be seen in the variables 'm' and 'a' there is a difference of 4.  My 
question is two fold: 1) How can I do this in Perl and get correct numbers?  
and, 2) If this requires a module, which one is it?

I may end up using even longer numbers, perhaps up to 20 or 30 digits.  It is 
likely that all numbers ($m) will be integers.


$m = 619175052916346;
#$m = 27;
print "m $m\n";
$r = $m ** (1/9);
print "r $r\n";
$a = 44.0083238414736;
$b = $a ** 9;
print "a $b\n";

Output...
m 619175052916346
r 44.0083238414736
a 619175052916350

Thank you,
...Robert Vaughn, Albuquerque, NM
___
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regular Expression question w/ long numbers

2006-01-09 Thread rv457

I am trying to do some simple regular expressions but just can't get them right.  
 
I have a very long number that I am trying to perform some reg ex funtions on.  When I put the long number in quotes, the reg ex works fine.  When I do ot use quotes, the number is viewed as numeric and the reg ex pulls out the scientific notation.
 
These are numbers and not strings.  How do I use the reg ex and get the proper numeric information?  I am familiar with Math::BigFloat but have not found a solution to my problem within that module.
 
It seems like a simpler question would be; how do I tell Perl to not convert my long numbers to scientific notation?
 
BTW I am using Active State v5.8.7 on Windows XP.
 
Following are code/output samples.
 
Example 1:
## Grab the last three digits after decimal\n"; $m = "7191750529163469.123"; # notice the double quotes, this is now a string print "$m\n"; $m =~ /(\d\d\d)$/; #Get the last three digits. print "$1\n";
 
Output:
7191750529163469.123123   (this is what I wanted the reg ex to pull out)
 
Example 2:
## Grab the last three digits after decimal\n";
 $m = 7191750529163469.123; # notice NO double quotes, this is still a number print "$m\n"; $m =~ /(\d\d\d)$/; #Get the last three digits. print "$1\n";
 
Output:
7.19175052916347e+015015   (this is NOT what I wanted the reg ex to pull out)
___
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Regular Expression question w/ long numbers

2006-01-10 Thread rv457

Thanks! This is what I'm looking for.
 
-- Original message -- From: "DePriest, Jason R." <[EMAIL PROTECTED]> > use Math::BigFloat; > $m = Math::BigFloat->new('7191750529163469.123'); # notice NO double > quotes, this is still a number > print "$m\n"; > $m =~ /(\d\d\d)$/; #Get the last three digits. > print "$1\n"; > > This gives: > 7191750529163469.123 > 123 > > which is what you are looking for I think. > > -Jason > > On 1/9/06, [EMAIL PROTECTED] <> wrote: > > > > I am trying to do some simple regular expressions but just can't get them > > right. > > > > I have a very long number that I am trying to perform some reg ex funtions > > on. When I put the long number in quotes, the reg ex works fine. When I do > > ot use quotes, the number is viewed as numeric and the reg ex pulls out the > > scientific notation. > > > > These are numbers and not strings. How do I use the reg ex and get the > > proper numeric information? I am familiar with Math::BigFloat but have not > > found a solution to my problem within that module. > > > > It seems like a simpler question would be; how do I tell Perl to not convert > > my long numbers to scientific notation? > > > > BTW I am using Active State v5.8.7 on Windows XP. > > > > Following are code/output samples. > > > > Example 1: > > ## Grab the last three digits after decimal\n"; > > $m = "7191750529163469.123"; # notice the double quotes, this is now a > > string > > print "$m\n"; > > $m =~ /(\d\d\d)$/; #Get the last three digits. > > p!
 rint "$1\n"; > > > > Output: > > 7191750
529163469.123 > > 123 (this is what I wanted the reg ex to pull out) > > > > Example 2: > > ## Grab the last three digits after decimal\n"; > > $m = 7191750529163469.123; # notice NO double quotes, this is still a > > number > > print "$m\n"; > > $m =~ /(\d\d\d)$/; #Get the last three digits. > > print "$1\n"; > > > > Output: > > 7.19175052916347e+015 > > 015 (this is NOT what I wanted the reg ex to pull out) > > ___ > > ActivePerl mailing list > > ActivePerl@listserv.ActiveState.com > > To unsubscribe: > > http://listserv.ActiveState.com/mailman/mysubs > > > > > > ___ > ActivePerl mailing list > ActivePerl@listserv.ActiveState.com > To unsubscribe: http://l!
 istserv.ActiveState.com/mailman/mysubs 
___
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Regular Expression question w/ long numbers

2006-01-10 Thread rv457

Thanks for the feedback.  I am studying prime factorization of very large numbers.  In particular, I am working on tests that work in the inverse of prime factorization.  In that, I mean that I am actually testing for composite numbers.
 
What is quicker; to determine if a number is prime or composite?  I need an extreme level of precision because rounding invalidates the protocols within which I can correctly calculate.
 
I'm using Perl because I can look at a number as a string, parse it at different points and more easily explore a variey of number theories.
 
Thank you,
...Robert Vaughn, Albuquerque, NM
 
 
 
-- Original message -- From: David Nicol <[EMAIL PROTECTED]> > On 1/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote: > > > It seems like a simpler question would be; how do I tell Perl to not convert > > my long numbers to scientific notation? > > keep them as strings, as you are doing. Why do you need such accuracy? > What process is generating real data that you are measuring to nineteen > digits of accuracy? > > Your so-called numbers might be better dealt with as entirely as strings. 
___
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs