Well, nobody seemed to have bothered asked the very first question!
fun:
Before I asked, though, will you please clarify something for me...in your posting, you say that a variable goes "larger than exp(-307)"...can you write this number in scientific notation...I am not 100 percent sure what it is.
Here are my questions:
Question 1.- Are the numbers supposed to get this large?
and then we continue:
Do you know the solution to your problem?
Have you tried your algorithm with a smaller problem you know the solution to?
before you go out on a wild goose chase looking for libraries, etc.
Although the solution suggested about reducing your number in the first place is not a bad idea...maybe, if you do not want to reduce your number right up front, you can do it once in a while and keep track how many times you have divided by 10...maybe you can divide by 10 (or 100 or whatever necessary) after every multiplication.
But, first, verify your algorithm is working correctly!
my 2 cents