mIRC Home    About    Download    Register    News    Help

Print Thread
#121344 26/05/05 11:01 AM
Joined: May 2005
Posts: 7
H
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
H
Joined: May 2005
Posts: 7
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

Last edited by HyperBlasT; 26/05/05 11:01 AM.

"A wasted day, is a day you didn't laugh in."
www.FunScripT.2ya.Co.iL
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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.

Joined: Dec 2002
Posts: 208
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Dec 2002
Posts: 208
$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.


If I knew now what I will know then... maybe things will have been different...
Joined: Jan 2004
Posts: 509
L
Fjord artisan
Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
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.

Joined: Dec 2002
Posts: 208
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Dec 2002
Posts: 208
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.


If I knew now what I will know then... maybe things will have been different...
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
[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.

Joined: Jun 2003
Posts: 5,024
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Jun 2003
Posts: 5,024


Mentality/Chris
Joined: Jan 2004
Posts: 509
L
Fjord artisan
Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Oh woops, I meant i to the i power is .20...etc.

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


Link Copied to Clipboard