mIRC Homepage
Posted By: AviN456 division by zero - 17/06/04 05:44 AM
$calc(N/0) should return an error message, not 0

mIRC 6.15 (and all others AFAIK)
Posted By: wiebe Re: division by zero - 17/06/04 10:28 AM
$calc(a + b) also gives 0

would indeed be nice if it gives an error
Posted By: cold Re: division by zero - 24/06/04 02:36 AM
I don't think so. To be consistent, identifiers should only halt the script with an error if there's wrong syntax. In all other cases, it depends on what the identifier does and what's the kind of parameters entered. $calc(1/0) deals with numbers, so I can't see a problem with it returning 0 in this case.

What I don't like are identifiers like $calc(), $int() and $abs() that return 0 when not only numbers are entered. In this case, I think they should return $null, since there should be no place for anything other than numbers (and operators, in $calc()'s case). For example, $calc(a/0) should return $null, in my opinion.
Posted By: Sais Re: division by zero - 24/06/04 08:06 PM
I agree. It might be nice to get a warning rather than an error (i.e. the script isn't halted, it just (optionally?) prints something to the status). I can't remember if there is anything else like this in mIRC already.

The onus should be on the scripter to make sure his/her script does not cause an error - they should make the effort to avoid such conditions as division by zero. If it were reported as an error it might help in debugging.

Posted By: tsoglanos Re: division by zero - 24/06/04 08:46 PM
see it from thy other site

if you run you Microsoft calculator

you can not add any text the are only Numbers from 0 to 9

0 is the error msg (a + b is 0) (1 + 2 is 3) , =)
Posted By: starbucks_mafia Re: division by zero - 24/06/04 11:19 PM
Personally I think division by 0 or any operation on invalid input should simply return $false. That way those who don't want to treat it differently from 0 can use if ($calc(whatever)) without any change and those that want to check can use if ($calc(whatever) != $false). However it should still behave the same with things like $calc(123abc) returning '123' since it's great to use as a $parseNum().
Posted By: AviN456 Re: division by zero - 06/07/04 12:23 PM
Quote:
0 is the error msg (a + b is 0) (1 + 2 is 3) , =)



in that case, think of a and b as variables
mathematically, until a variable is assigned a value, it has a value of zero.
© mIRC Discussion Forums