exponent and power problems, please help
I am writing code that deals with very small numbers. I am having problems with these small numbers getting set to zero. I am using gcc in RedHat 9. For example, if I declare x to be a long double, and I then say
x = pow(10, -400)
I get that my program thinks x is 0. The magic exponent at which x is set to zero appears to be -325. Additionally, if I say
x = pow(10,-324)
I get x to be equal to about 9.88E-324. I have roughly the same problem with the exp() function. I've tried setting LDBL_MIN_EXP and LDBL_MIN_10_EXP, but it doesn seem to work. Does anyone know what is going on? What am I doing wrong, or what am I not doing? Do I have to recompile something (besides my program) after I set LDBL_MIN_EXP or LDBL_MIN_10_EXP?
Thanks for your time,
Andreas
RH 9 gcc -- exponentially small numbers getting set to zero
Thanks bennyandthejets and Salem,
Since bennyandthejets asked, I am trying to numerically integrate a function that involves a sensitive exponential. The exponential function looks like
exp(-a/(T(1-T^4)^2)
Here 'a' is a relatively large number and 'T' varies from 0 to 1. If you are curious, I am looking at how the universe goes through a first-order phase transition. The exponential describes how many bubbles (of protons and neutrons) form in the universe as it cools. The 'T' in the above equation is a dimensionless temperature. These bubbles then grow as the universe evolves. So, what started out as an extremely small bubble can grow to macroscopic sizes. Therefore, I need to keep exponentially small numbers.
I've looked briefly at what you both suggest. I'm not sure which one will be best for me at this point. I'll give try one and then get back to you.
Thanks again for your time.
Andreas