08-09-2010
Your problem is due to the magnitude of the exponent i.e. 100.
The error in pow(x, y) is below about 2 ulps (Unit in Last Place or Unit of Least Precision) when its magnitude is moderate, but increases as pow(x, y) approaches the over/underflow thresholds until almost as many bits can be lost as are occupied by the floating-point format's exponent field, i.e. 11 bits for an IEEE 754 double. Moderate values of pow() are accurate enough that pow(int, int) is exact until it is bigger than 2**53 for IEEE 754. I do not have figures to hand for pow(int, double) but I seem to recall that there is no much difference.
If you require accuracy in the 2**100 range you need to use a arbitrary precision numeric library and not libm. Given that you appear to be on a DOS or WIN32 platform, this option may not be available to you.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Was wondering if you could give me an example of extracting a 10 digit number from 5 txt files using a regular expression (the number is always different ) and storing the numbers in variables
Thanks
C19 (9 Replies)
Discussion started by: c19h28O2
9 Replies
2. Shell Programming and Scripting
Hi Can any one please post the answer for the above program.................. (4 Replies)
Discussion started by: banta
4 Replies
3. Shell Programming and Scripting
i am new to shell scripting. i want to keep on increamenting a 6 digit number. For eg. 000000 + 1 = 000001 But instead of 000001 i get only 1. How do i do this ? Pls help. (8 Replies)
Discussion started by: kanchan_cp
8 Replies
4. Programming
Hi,
How can we generate 16 digit random nos in C. (10 Replies)
Discussion started by: ajaysahoo
10 Replies
5. UNIX for Dummies Questions & Answers
how can i list all files in my home directory that have a 4 digit id number, the line number where the id is located and the id itself not printing the entire line? (5 Replies)
Discussion started by: hobiwhenuknowme
5 Replies
6. Shell Programming and Scripting
I want to write/print a number through a shell script up to its last significant digit (LSD) after the decimal point.
Say,
x=10.00056000000000000
I want to print x as x=10.00056.
Note that x can be any thing so I cannot know the position of the LSD always.
Thanks. (16 Replies)
Discussion started by: hbar
16 Replies
7. Shell Programming and Scripting
Hello Team,
i have a file test1.txt, in which i have to grep only the 6 digit number from it,
Could you pls help in this.
$cat test1.txt
<description>R_XYZ_1.6 r370956</description>
$ grep "\{6\}" test1.txt
<description>R_XYZ_1.6 r370956</description>
i need output as 370956.
... (3 Replies)
Discussion started by: chandana hs
3 Replies
8. Shell Programming and Scripting
Dear All,
Lets say I have a number with following format:
####.12e-##
now I want to compare place holder in position 1 and 2.
How can I do that?
Note: My number is stored in a variable say var.
example:
var=9999.12e-05
Thanks & Regards,
linuxUser_ (6 Replies)
Discussion started by: linuxUser_
6 Replies
9. UNIX for Beginners Questions & Answers
I am trying to process only IonCode_odd #'s (always 4 digits starting with zero), but the below isn't working as expected. Is there a better way? Thank you :).
IonCode_0401_xxxx_xxxx_xxxx.bam
IonCode_0401_xxxx_xxxx_xxxx.bam.bai
IonCode_0401_xxxx_xxxx_xxxx.fastq... (2 Replies)
Discussion started by: cmccabe
2 Replies
10. UNIX for Beginners Questions & Answers
I all
I am tryng to find a way to sort a list of number in a file by the value of last two digit.
i have a list like this
313202320388
333202171199
373202164587
393202143736
323202132208
353201918107
343201887399
363201810249
333201805043
353201791691 (7 Replies)
Discussion started by: rattoeur
7 Replies
exp(3m) exp(3m)
Name
exp, expm1, log, log10, log1p, pow - exponential, logarithm, power
Syntax
#include <math.h>
double exp(x)
double x;
float fexp(x)
float x;
double expm1(x)
double x;
float fexpm1(x)
float x;
double log(x)
double x;
float flog(x)
float x;
double log10(x)
double x;
float flog10(x)
float x;
double log1p(x)
double x;
float flog1p(x)
float x;
double pow(x,y)
double x,y;
Description
The and functions return the exponential function of x for double and float data types, respectively.
The and functions return exp(x-1 accurately, including tiny x for double and float data types, respectively.
The and functions return the natural logarithm of x for double and float data types, respectively.
The and functions return the logarithm of x to base 10 for double and float data types, respectively.
The and functions return log(1+x) accurately, including tiny x for double and float data types, respectively.
The function returns x**y.
Error (due to roundoff)
The and functions are accurate to within an ulp, and is accurate to within approximately 2 ulps; an ulp is one Unit in the Last Place.
The function is accurate to within 2 ulps when its magnitude is moderate, but becomes less accurate as the result approaches the overflow
or underflow thresholds. Theoretically, as these thresholds are approached, almost as many bits could be lost from the result as are indi-
cated in the exponent field of the floating-point format for the resultant number. In other words, up to 11 bits for an IEEE 754 double-
precision floating-point number. However, testing has never verified loss of precision as drastic as 11 bits. The worst cases have shown
accuracy of results to within 300 ulps for IEEE 754 double-precision floating-point numbers. In general, a (integer, integer) result is
exact until it is larger than 2**53 (for IEEE 754 double-precision floating-point).
Return Values
All of the double precision functions return NaN if x or y is NaN.
The function returns HUGE_VAL when the correct value would overflow, and zero when the correct value would underflow.
The and functions return NaN when x is less than or equal to zero or when the correct value would overflow.
The function returns NaN if x or y is NaN. When both x and y are zero, 1.0 is returned. When x is negative and y is not an integer, NaN
is returned. If x is zero and y is negative, -HUGE_VAL is returned.
The function returns NaN when x is negative.
See Also
math(3m)
RISC exp(3m)