Shoutbox

How to check the Plus! version - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: How to check the Plus! version (/showthread.php?tid=68347)

How to check the Plus! version by Choli on 11-12-2006 at 11:05 AM

Original Subject: "dodgy bug in scripting"

With the current version (4.10.250), MsgPlus.Version returns 4.099999904632568, which is not equal to 4.10. I was wondering why this code didn't work as i expected

code:
if (MsgPlus.Version < 4.10) {
    Debug.Trace("You have an old version of Plus");
}
and I was surprised when I did "Debug.Trace(MsgPlus.Version);" and i showed 4.099999904632568. :O
RE: dodgy bug in scripting by NiteMare on 11-12-2006 at 11:59 AM

confirmed, i got 4.09999990463257


RE: dodgy bug in scripting by Mnjul on 11-12-2006 at 12:00 PM

Always use epsilon comparison (or something like that) when comparing floating-point numbers.

Well, at least that's what I do when I code in C/C++... :p


But I think this can be fixed though...causing confusion for basic scripters.
RE: dodgy bug in scripting by Choli on 11-12-2006 at 12:10 PM

quote:
Originally posted by Mnjul
Always use epsilon comparison (or something like that) when comparing floating-point numbers.
if in my code, that number (4.0999...etc) is not equal to 4.10, that means that 4.10 - 4.0999... is bigger than epsilon, so even if i've used epsilon, the comparision would have been different.

quote:
Originally posted by Mnjul
But I think this can be fixed though...causing confusion for basic scripters.
yes, of course; and not only for basic developers. For me its a pain to calculate, for each new version of plus, which is the value returned by msgplus.version... and not to mention that that value seem to be diferent depending on ... on what? NiteMare's Plus returns a value diferent from mine.
RE: dodgy bug in scripting by Patchou on 11-15-2006 at 04:54 AM

Fixed... nothing annoys me more than the stupid floating point data types of C++...


RE: dodgy bug in scripting by Choli on 11-16-2006 at 08:36 PM

quote:
Originally posted by Plus' changelog
Scripts MsgPlus.Version returns a more usable floating point value (see update in documentation).
Well, in fact MsgPlus.Version returns a more usable value... for me it returns now 4.101010322570801, which in my code it works ok, but it still may fail, if you compare with ">" instead with "<" (because 4.101010322570801 is not the same as 4.10).

ok, ok... i'm being picky :P... if I had to choose, i'd choose 4.101010322570801 (like it's now) instead of 4.099999904632568 (like before).

but maybe MsgPlus.Version could return an integer..., couldn't it? What about returning 4100 or 4010? That would make no confusion. I know, that changing the type (and value) of the returned number will cause backwards incompatibilities, but IMO, returning an integer would be the best option.

on the other hand, in the changelog, Patchou, you talk about a new documentation... where can we download it from? ... i know i should have read it before posting, maybe in the documentation there's something I haven't noticed :P
RE: dodgy bug in scripting by CookieRevised on 11-17-2006 at 01:59 AM

while playing with it (and reading up on som IEEE docs) I found:
http://babbage.cs.qc.edu/IEEE-754/Decimal.html

dunno how representative or usefull this is. Seems like single precision doesn't yield the accurate result, double precision does.


RE: dodgy bug in scripting by Patchou on 11-17-2006 at 07:07 AM

The documentation will be updated with an indication that the equal operator should not be used, instead, use "more than" or "less than". The change is that you'Re now guarenteed that the value returned will always be slighly above the exact version number, I can't do any better than that.

If you want a fixed integer, you already have it: the build number :).


RE: dodgy bug in scripting by Choli on 11-17-2006 at 10:07 AM

quote:
Originally posted by CookieRevised
Seems like single precision doesn't yield the accurate result, double precision does.
4.1 is a periodic number in base 2, it doesn't matter if you choose single or double precission
quote:
Originally posted by Patchou

The documentation will be updated with an indication that the equal operator should not be used, instead, use "more than" or "less than". The change is that you'Re now guarenteed that the value returned will always be slighly above the exact version number, I can't do any better than that.
it's ok with that (Y)
quote:
Originally posted by Patchou
If you want a fixed integer, you already have it: the build number
<picky mode>
i can't use the build number:
quote:
Originally posted by scripts documentation
For safety reasons, the build number should always be paired with the major/minor version number of Messenger Plus!. Build numbers are not guaranteed to stay sequential between two new major versions of Messenger Plus!.
just being picky :P
</picky mode>
RE: dodgy bug in scripting by Patchou on 11-17-2006 at 06:25 PM

Just check if its version 4 or 5 and you'll be ok with the build number :)


RE: dodgy bug in scripting by CookieRevised on 11-17-2006 at 10:00 PM

quote:
Originally posted by Choli
quote:
Originally posted by CookieRevised
Seems like single precision doesn't yield the accurate result, double precision does.
4.1 is a periodic number in base 2, it doesn't matter if you choose single or double precission
That page I linked to does tell/show it makes a big difference though (also the docs I've read on it -quickly- say it does) :/ ....

---------------------

EDIT:

- Requested thread to be moved to public scripting forum.

- For those who whish to check versions, use something like this to avoid the floating point trap and to have an as accurate as possible build check:
code:
function _isValidVersion(nSoftwareBuild) {
        return parseInt(MsgPlus.Version) * 1000 + MsgPlus.VersionBuild >= nSoftwareBuild
}
Where nSoftwareBuild is a number in the form of 4244, 4250, 5398, etc...

This is the exact same method used by Plus! itself to check for updates and stuff. And since the major version number and build number will always uniquely define the installed version (the minor version number doesn't matter).

The function will return true if the user's version is equal or higher than the requested softwarebuild.