[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] [Tomasz] 1 / 0 = 0?



PureBytes Links

Trading Reference Links

Quite often TA formulas can lead to attempted divide by zero (sepecially
where volume is involved in calcs). Assuming there is no logic error usually
the best solution for realistic results is to replace the zero value with a
very small value e.g. 0.00000001 using emebedded code for this purpose.

So would it not be better to display a "Divide by Zero" exception error
message giving the symbol, bar no., date, time etc. Once a user gets this
they can then take defensive steps to trap/prevent zero division in their
formula.

John

----- Original Message -----
From: "Anthony Faragasso" <ajf1111@xxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Monday, March 03, 2003 11:18 AM
Subject: Re: [amibroker] [Tomasz] 1 / 0 = 0?


> Do you really think that is NECESSARY ?
>
> Anthony
>
> -------Original Message-------
>
> From: amibroker@xxxxxxxxxxxxxxx
> Date: Monday, March 03, 2003 05:19:30
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: Re: [amibroker] [Tomasz] 1 / 0 = 0?
>
> Hello,
>
> When I am thinking more on this... maybe it would be better
> to display a special string "NaN" in such case?
>
> I will modify the WriteVal and this division handling so
> it displays NaN string so it is more obvious what happens.
>
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message -----
> From: "Tomasz Janeczko" <amibroker@xxxxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Monday, March 03, 2003 8:57 AM
> Subject: Re: [amibroker] [Tomasz] 1 / 0 = 0?
>
>
> > Hello,
> >
> > (30/0) is NaN - NOT a NUMBER
> >
> > Division by zero is illegal operation.
> >
> > If there was no protection against dividing by zero
> > the program would just bomb out (crash and say good bye).
> >
> > Therefore when dividing two numbers X / Y AB checks
> > if Y is equal to zero and always returns zero in that case.
> >
> >
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message -----
> > From: <mik-u@xxxxxxxxxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Monday, March 03, 2003 4:00 AM
> > Subject: [amibroker] [Tomasz] 1 / 0 = 0?
> >
> >
> > > Tomasz,
> > >
> > > AB returning 0 for an expression like 1 / 0. Is it correct?
> > >
> > > The following expression
> > >
> > > 100 - 100 / (1 + 30 / 0)
> > >
> > > is equal 0 in AB, but I think it should be equal 100.
> > >
> > > Thanks,
> > > Mike
> > >
> > >
> > >
> > > Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> > > Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> > > -----------------------------------------
> > > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> > > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > > --------------------------------------------
> > > Check group FAQ at: http://groups.yahoo
> com/group/amibroker/files/groupfaq.html
> > >
> > > Your use of Yahoo! Groups is subject to http://docs.yahoo
> com/info/terms/
> > >
> > >
> > >
> >
> > Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> > Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> > -----------------------------------------
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > --------------------------------------------
> > Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq
> html
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
> >
>
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq
> html
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
> .
>
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/