What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Convert Boolean to Numeric?

Convert Boolean to Numeric?
Author: Message:
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: Convert Boolean to Numeric?
quote:
Originally posted by markee
quote:
Originally posted by phalanxii
I believe Math.abs(<boolean>) also does that.
This will give the absolute value of the number which is not what you want.  Boolean expressions are equivalent to 1 for true, 0 for null and -1 for false and thus you would have a problem where you couldn't tell the difference between true and false.  Even Spunky's code is incorrect because it misses the null possibility and false should be negate one not zero.  The proper methods would be either to use the parseInt method or multiply the boolean variable by 1 (or minus zero).  This is also the same when you try to convert a string to a number.

....multiplying -1 by 1 wouldn't produce 0 as he wanted, under your logic. false is equal to 0.
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
10-04-2007 02:04 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Convert Boolean to Numeric? - by stu on 10-03-2007 at 07:18 PM
RE: Convert Boolean to Numeric? - by Spunky on 10-03-2007 at 07:22 PM
RE: Convert Boolean to Numeric? - by stu on 10-03-2007 at 07:42 PM
RE: Convert Boolean to Numeric? - by markee on 10-03-2007 at 11:52 PM
RE: Convert Boolean to Numeric? - by phalanxii on 10-04-2007 at 12:33 AM
RE: Convert Boolean to Numeric? - by markee on 10-04-2007 at 12:44 AM
RE: Convert Boolean to Numeric? - by phalanxii on 10-04-2007 at 01:05 AM
RE: Convert Boolean to Numeric? - by deAd on 10-04-2007 at 01:22 AM
RE: Convert Boolean to Numeric? - by phalanxii on 10-04-2007 at 01:32 AM
RE: Convert Boolean to Numeric? - by deAd on 10-04-2007 at 01:37 AM
RE: Convert Boolean to Numeric? - by ShawnZ on 10-04-2007 at 02:04 AM
RE: Convert Boolean to Numeric? - by stu on 10-04-2007 at 03:04 AM
RE: Convert Boolean to Numeric? - by Spunky on 10-04-2007 at 11:51 AM
RE: Convert Boolean to Numeric? - by -dt- on 10-04-2007 at 02:21 PM
RE: Convert Boolean to Numeric? - by Matti on 10-04-2007 at 04:52 PM
RE: Convert Boolean to Numeric? - by markee on 10-04-2007 at 10:41 PM
RE: Convert Boolean to Numeric? - by Voldemort on 10-04-2007 at 11:01 PM
RE: Convert Boolean to Numeric? - by Spunky on 10-05-2007 at 12:40 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On