HOWTO: Fix "Divide by zero in Calculation" issues

General announcements relating to the modularized MacroQuest2 system.

Moderator: MacroQuest Developers

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

HOWTO: Fix "Divide by zero in Calculation" issues

Post by Lax » Mon Jun 21, 2004 3:53 pm

Currently, all division by zero in calculations will report a fatal macro error. Previously, they would silently give 0 (e.g. no error, and no indication that you tried to divide by zero.. just gave you 0).

The following will give you an error:
${Math.Calc[1/0]}

Even if it is placed inside an ${If}, which will never use it, like this:
${If[0,${Math.Calc[1/0]},FAILED]}

This will always give "FAILED" because it will never use the 1/0 calculation. However, it will always give the divide by zero error! The reason for this is all of the inside ${} are handled before the outside ${}. -- The calculation is done before the If is.

To solve this issue, put the If inside the Calc, so that the If is handled before the calculation:
${Math.Calc[1/${If[0,0,9999999]}]}

This case will never give a divide by zero error, because the 0 part of the If is never used.

Have fun ;)
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0