mIRC Homepage
Posted By: DaveC Integers with $int - 08/10/03 11:09 PM
Not really a bug as it does what the help file says it does.

But i always thought a integer value was the next whole number below what ever number you have.

$int(%x) doesnt do this of course
Posted By: starbucks_mafia Re: Integers with $int - 08/10/03 11:21 PM
Depends exactly what you mean by 'next whole number below what ever number you have'.

If you mean $int(56) should return 55 then no, that's not what an integer function should do. However, $int(55.99) should return 55 (and does) since all it's doing is ignoring the floating point part altogether.

If that's not what you mean then could you give an example?
Posted By: DaveC Re: Integers with $int - 08/10/03 11:36 PM
Sorry yes i shopuld have been more exact as to what it doesnt do.

And nope i wouldnt expect 56 to return 55, i ment to move down from any decimal part of a number to the next whole value, 56.000001=56 56=56 59.99999=59
but i would expect this to maintain to -34.4=-35

** remember here im not actually saying this is a bug - since the help does not say this is the nature of the command **
Rather I believe that is in fact what the integer of a value is, such as VB produces the next lower whole number
Posted By: RedAlert Re: Integers with $int - 08/10/03 11:36 PM
Well, for one thing, $int(-3.99) returns -3, whereas in maths |-3.99| would be -4 if I'm not mistaken...maybe that's what he means?
Posted By: Iori Re: Integers with $int - 08/10/03 11:46 PM
Maybe $floor is what you want. smile
Posted By: starbucks_mafia Re: Integers with $int - 08/10/03 11:52 PM
Well although people generally say 'lower' they actually mean 'closer to zero'. This is the way that most computer languages calculate integers. I would assume that corresponds to the traditional mathematical definition for integers, but I really don't know for sure.
Posted By: codemastr Re: Integers with $int - 08/10/03 11:52 PM
In math, |-3.99| = 3.99 (|x| is an absolute value).
If you meant [-3.99] = -4 then yes you are correct, that would be -4. However, in programming, the int() function doesn't do this. It returns the "integer part" of the number. I think this is correct because mIRC does this with many identifiers. One example, $log. In math log() is base 10 and ln() is base e. In mIRC $log is base e. Again, in programming this is how it is, in C for example log() is base e and log10() is base 10. Seeing as how everywhere else mIRC follows the "programming" definition of the function, I think the way mIRC handles $int is correct.

IMHO the easiest way for this to be solved would be by adding $floor and $ceil to mIRC.
Posted By: Iori Re: Integers with $int - 08/10/03 11:56 PM
Quote:
IMHO the easiest way for this to be solved would be by adding $floor and $ceil to mIRC.
They have been added. laugh
Posted By: RedAlert Re: Integers with $int - 08/10/03 11:56 PM
You're right. I always sucked at all those math symbols. smile

Note that $floor and $ceil were added in mIRC 6.1
Posted By: DaveC Re: Integers with $int - 09/10/03 12:02 AM
VB makes it -4 cant think what some others do off the top of my head (actually i donty even have VB on this machine but im sure it does that), But im not complaining. Im just off now to bludgen my eyes out for not seeing thr $floor command on the line above $int in the help file.
Posted By: codemastr Re: Integers with $int - 09/10/03 02:48 AM
Hmm, I'll take your word for it, I don't use 6.1 so I wouldn't know.
Posted By: codemastr Re: Integers with $int - 09/10/03 02:49 AM
Yeah well that's cause VB is... well... VB. I'd never use VB as "the rule," I always consider what it does as the exception :P
© mIRC Discussion Forums