Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: Loss of information using small numbers (e10), MEX, C++
Posted:
Dec 30, 2013 9:49 AM


"James Tursa" wrote in message <l9r887$ck9$1@newscl01ah.mathworks.com>... > > What is pi? If it is 0 then your result will be zero. Maybe you forgot to set it? Did you >include math.h?
pi is defined earlier in the code: long double pi = 3.1415926535897932384626433832795028841971693993751; math.h is included.
> Also the pow calls are in double, so you are not going to get the benefit of long double >precision for those calculations (if it is longer than a double).
I did not think about that, but guss it will do with double as the number is of magnitude 1500^2=2250000. I assume it is automaticaly typecasted to long when i multiply/divide with other long variables. So that is does not affect the precision of the other variables. > > Also, your code is not robust and will bomb MATLAB if things are not exactly as expected. E.g., if pSettings is missing then MATLAB will bomb. If the ro field is missing then MATLAB will bomb. Etc. You might consider putting in code to check to see that the inputs are exactly as expected before using them.
A good point. It is part of a bigger .m program, but I can put in some error messages to ease debugging in the "caller" at a later point. > > James Tursa



