mIRC Home    About    Download    Register    News    Help

Print Thread
#98568 24/09/04 11:15 PM
Joined: Sep 2003
Posts: 20
E
emull Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Sep 2003
Posts: 20
In other programming languages, there is the Integer type, and the int() function. These are easily confused.

The general definition of the int() function, means the integer part of N. It is, in fact, the greatest integer which is not greater than N.

Examples such as $int(-2.4) proves mIRC incorrect. This should infact be -3.

Usually, the int() provided in mIRC would be denoted fix().

Here follows a substitute for $int:

alias _int {
var %int = $int($$1)
return $iif(%int > $1,$calc(%int - 1),%int)
}

#98569 25/09/04 12:59 AM
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Quote:
Examples such as $int(-2.4) proves mIRC incorrect. This should infact be -3.

According to your definition, yes. According to mIRC, no. There's no obligation for mIRC to conform to your definition, or any definition at all for that matter, so this is not a bug.

Anyway, instead of your scripted $_int you can just use $floor.

See also this lengthy discussion about the issue.


Saturn, QuakeNet staff
#98570 25/09/04 01:06 AM
Joined: Sep 2003
Posts: 20
E
emull Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Sep 2003
Posts: 20
Ah, sorry for my ignorance smile

But I would like to point out that it is not my definition, rather a *general* one.

#98571 25/09/04 01:19 AM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
The common method for converting to integers is to simply remove the floating-point aspect of a number, that is, to round the number towards zero. This is the way that integer casting and conversion works in all computer languages I've used.

Edit: Too late. Damn slow typing...

Last edited by starbucks_mafia; 25/09/04 01:20 AM.

Spelling mistakes, grammatical errors, and stupid comments are intentional.

Link Copied to Clipboard