123456*123456 = 15,241,383,936 or -1,938,485,248 ?

Questions about MultiCharts and user contributed studies.
2haerim
Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

123456*123456 = 15,241,383,936 or -1,938,485,248 ?

Postby 2haerim » 08 Mar 2010

Compare the following two:

[1] Insert Custom 1 Line with 123456*123456 as the input parameter
=> shows -1,938,485,248 (Wrong! )
[2] Insert another indicator with the following code:
Plot1(123456*123456);
=> shows 15,241,383,936 (Correct )

HR

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 08 Mar 2010

One is a 32 bit integer (max approx. 4 billion, or approx. 2 billion if both positive and negative are permitted) while one is a floating point number.

2haerim
Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

Postby 2haerim » 08 Mar 2010

One is a 32 bit integer (max approx. 4 billion, or approx. 2 billion if both positive and negative are permitted) while one is a floating point number.



=> Where do you find such detail information?


=> Is it NOT possible to input such a big value no matter what it is floating or integer?



thx

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 08 Mar 2010

Well, I simply understand how the expression you typed is interpreted because that's how EL works. Try this instead: 123456.0 * 123456.0 - if you do this, they will both be floating point numbers, and not interpreted as integers, and thus, not limited to about 2 billion.

LMC
Posts: 28
Joined: 08 Jul 2010

"Floating point number too big"

Postby LMC » 21 Jan 2011

Hi Bruce,

Can you help me understand what is 'Floating point" ?

I put this into a strategy and it returns the captioned error message.

Value1 = 6.9273023605346680 - (ARN + expValue(((expValue(((-9.2743015289306641) - SK2N)) * (6.9273023605346680 + ARN)) - (((-7.3906569480895996) * C9N) / ARN))));

How can I get around this ? Thanks !

LMC

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 485 times

Re: 123456*123456 = 15,241,383,936 or -1,938,485,248 ?

Postby Dave Masalov » 21 Jan 2011

Dear LMC,

Probably, it is division by zero error. Please try one of the following:

1. Add the condition:

if ARN = 0 then ARN = 1;

2. Do not calculate value1 when ARN = 0:

if ARN = 0 then value1 = 0 else
Value1 = 6.9273023605346680 - (ARN + expValue(((expValue(((-9.2743015289306641) - SK2N)) * (6.9273023605346680 + ARN)) - (((-7.3906569480895996) * C9N) / ARN))));

LMC
Posts: 28
Joined: 08 Jul 2010

Re: 123456*123456 = 15,241,383,936 or -1,938,485,248 ?

Postby LMC » 21 Jan 2011

Hi Dave,

I set a condition to not calculate if any one of the variables are zero, but the same error message returned. Any other possibilities ? Thanks.

LMC

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 485 times

Re: 123456*123456 = 15,241,383,936 or -1,938,485,248 ?

Postby Dave Masalov » 24 Jan 2011

Dear LMC,

Then exception occurs when going beyond type double. You have a complex statement, exp is calculated twice. You can use the following script to track the exception:

once cleardebug;
once for value1 = 0 to 10 begin
value2 = expvalue(expvalue(value1));
print("n = ", value1, "; exp(exp) = ", value2);
end;

You need to apply this to your chart and look at the output.

LMC
Posts: 28
Joined: 08 Jul 2010

Re: 123456*123456 = 15,241,383,936 or -1,938,485,248 ?

Postby LMC » 24 Jan 2011

Thanks Dave.
Some of the calculated values are indeed huge. I'm figuring out ways to get it around.

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 485 times

Re: 123456*123456 = 15,241,383,936 or -1,938,485,248 ?

Postby Dave Masalov » 24 Jan 2011

You are welcome.


Return to “MultiCharts”