I have a text file with numbers in scientific notation stored as a string of characters, some of which have up to 20
digits. For example, 2.3456789e-015
. I need to convert this into a long double in order to perform some mathematical operations on it.
How can I accomplish this?
long double number = 2.3456789e-015;
I know I can declare a long double like so, but the trouble comes when I have the number as a string and need to specify the base as well as the exponent separately. The pow()
function only works on doubles and cpowl()
has no way to be formatted in printf
. It is important that I keep the precision!!