Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Whilst pondering a post on another forum, I came up with yet another issue MS has with its math operations.
If the largest floating point number is of the order 1E+37 (even in single precision) then the maximum value which can be computed with causing an overflow in the Exp() function should be of the order 85.1956484 However, a brief experiment has shown MS to be computing Exp(88.722835540) without overflow and returns a value 3.4E+38
An oddity, or a bug?
wabbit [:D]
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 2/14/2012(UTC) Posts: 20
|
Hi Wabbit,
Can you please provide the steps that you followed to come up with these values so that we can learn from this issue as well,
Also, is MS using a double rather than a float?
Thanks,
Niall
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Resolved -> My error.
I was looking at different version of header file for FLT_MAX; the 'wrong' version says 1E+37, the correct value, as provided with MS Visual Studio and BloodShed, is 3.402823466e+38F, so MS computations are correct and the limit for Exp() is 88.722835540
wabbit [:D]
Niall, As the data format for MS was developed in the days of QBasic and DOS, the programmers decided to sacrifice small amounts of accuracy for the saving of space and efficiency of floating point values instead of double values. To find the max value for the Exp() function, I simply used a calculator to find the values what should be allowed and what should cause errors and entered both of these into a formula in MS.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
For Info:
Calculator: exp(88.722839051955126904272256737619) = 3.402823466e+38 MetaStock: Exp(88.722839051) [truncated] = Overflow error
Calculator: exp(88.722835540) = 3.4028115154576675276243308500424e+38
MetaStock : Exp(88.722835540) = 3.40279851902147610e+38F
so still some precision errors, as expected.
wabbit [:D]
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.