mIRC Homepage
Posted By: HyperBlasT Bug in the $calc identifier - 26/05/05 11:01 AM
My friend, SuperDude, found a bug in this identifier

Code: //echo -a $calc(1 / 0) return 0
Its supposed to return nothing.
cuz 0/1 is a insignificant value
Posted By: DaveC Re: Bug in the $calc identifier - 26/05/05 11:30 AM
Well based on what you say then its not a bug becuase 0 is also a insignificant value.

However what you say is incorrect in the fact that its an infinate or uncalculatable value that results from ( 1 / 0 )

Some languages give of results like "NAN" or "Infanite" (something like that i cant remember right now the wording), but im fine with mirc showing 0, the equation is almost always a bust otherwise.
Posted By: Hrung Re: Bug in the $calc identifier - 26/05/05 06:04 PM
$calc treats all invalid/undefined expressions as 0. For example, $calc((-1)^.5), which is the square root of -1, returns 0. $calc(a) returns 0, because a isn't a number. You are better off writing your script so that it doesn't try to evaluate such expressions, because mirc won't be able to give you any useful information anyway. I think that this is all a part of this change made in version 5.51:

61.$calc() now treats $null values as zero.

It's not a bug, but a feature, useful or not.
Posted By: LostShadow Re: Bug in the $calc identifier - 29/05/05 04:10 AM
In that case, it shouldn't be zero because the square root of negative one comes out to be around .207879576...

It's like $pi, but mIRC will round off at digits.
Posted By: Hrung Re: Bug in the $calc identifier - 29/05/05 07:17 AM
Quote:
the square root of negative one comes out to be around .207879576...


I don't know how far you got in math, but .207879576^2 is definately not -1, or even anywhere close to it. The square root of a negative number is called an imaginary number, because it does not fall anywhere within the set of real numbers, which include all rational and irrational numbers, even pi. The square of any real number is always positive, so there is no real square root of a negative number.

In other news, I think it would be spiffy to see mirc support complex numbers.
Posted By: DaveC Re: Bug in the $calc identifier - 29/05/05 09:40 AM
[quotecomplex numbers[/quote]

Ill show my ignorance and ask what a complex number is as aposed to say a normal? uncomplex number?

/me sees the dunce cap going to be passed to me any second.
Posted By: Mentality Re: Bug in the $calc identifier - 29/05/05 10:02 AM
Wikipedia/Complex_numbers

Google - define:complex numbers

Regards,
Posted By: LostShadow Re: Bug in the $calc identifier - 29/05/05 09:56 PM
Oh woops, I meant i to the i power is .20...etc.

Haven't checked what that returns in mIRC's $calc() identifier yet.
© mIRC Discussion Forums