User Tag List

Results 1 to 9 of 9

Thread: is there an equation that will return 1 for a certain number and 0 for anything else?

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,501
    Mentioned
    131 Post(s)
    Tagged
    0 Thread(s)

    is there an equation that will return 1 for a certain number and 0 for anything else?

    is there an equation that will return 1 for a certain number and 0 for anything else? So, say I want to test whether some value is equal to 47, but I want to be able to do it right inside an expression, rather than as a separate condition - is there some way to make an equation turn 47 into 1, while any other number will result in 0? Perhaps using one of the bitwise operators or something?

    I've been using the Immediate If object for this (ie. to squeeze a condition inside an expression) but if there's a mathematical and extension-less way I think I'd prefer to use that.

  2. #2
    Clicker Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    198
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Code:
    Floor(( 2.7183 pow ( -1 * ( ( Value - 47 ) pow 2 ) ) ))
    Normal distribution.

  3. #3
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2015
    Location
    Australia
    Posts
    219
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by defisym View Post
    Code:
    Floor(( 2.7183 pow ( -1 * ( ( Value - 47 ) pow 2 ) ) ))
    Normal distribution.
    Whoa this is cool - is 2.7183 a constant that works for every value or did you derive it from the target 47 somehow

    edit: ah, that's eulers number. woops, been a couple decades since I last looked at it and wondered why it was familiar

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export Module
    conceptgame's Avatar
    Join Date
    Apr 2011
    Location
    Switzerland
    Posts
    762
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Or, you can use the following if you only use integers:
    Abs(Min(Abs(Value - 47),1)-1)

  5. #5
    Clicker Fusion 2.5 (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Nov 2017
    Posts
    112
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Looks like you got your answer. So yo, Vol - how is Spryke coming along? Would be cool to hear the latest on it!

  6. #6
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,501
    Mentioned
    131 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by defisym View Post
    Code:
    Floor(( 2.7183 pow ( -1 * ( ( Value - 47 ) pow 2 ) ) ))
    Normal distribution.
    That's like magic

    I don't trust myself to remember to type it correctly though. But seeing this gave me some ideas of slightly simpler ways of doing it. Seeing you use pow got me thinking in that direction, and I thought this might get me there:

    Code:
    ( Value - 47 ) pow 0
    In Excel, this returns 1 for all wrong numbers, and a #num error for the right number. I hoped that in Fusion it would simply return a 0 for the right number. Though actually just returns 1 for everything. But I ended up with this, which is still relatively short (and will be easier for me to remember than the Euler's number-based one):

    Code:
    ( ( Value - 47 ) / ( Value - 47 ) ) xor 1
    If the number is correct (47) it will produce a divide-by-zero scenario, which Fusion graciously turns into an error-free zero. That gives 1 for all the wrong numbers, and 0 for the right one. The XOR 1 then flips that around, so all the 1s become 0s and 0 becomes 1.

    Thanks for your help, guys

    @Progject : I started answering your question about Spryke, but eventually turned it into its own post on the Spryke thread

  7. #7
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    679
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    @Volnaiskra try Max(1 - Abs(Value A - Value B), 0). If A = B it returns 1, else 0. Works for all decimal places.

  8. #8
    Clickteam Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    BartekB's Avatar
    Join Date
    Aug 2013
    Posts
    655
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Volnaiskra View Post
    Code:
    ( ( Value - 47 ) / ( Value - 47 ) ) xor 1
    If the number is correct (47) it will produce a divide-by-zero scenario, which Fusion graciously turns into an error-free zero. That gives 1 for all the wrong numbers, and 0 for the right one. The XOR 1 then flips that around, so all the 1s become 0s and 0 becomes 1.
    If you'd like to get rid of the brackets, this also pretty much does the same thing:
    Code:
    (1 - a xor b / a xor b)
    Operations in order:
    - Highest priority: xor gives 0 if both left and right values are the same.
    - Second highest: division gives 1 if both left and right values are the same except for 0.
    - Last: subtraction inverses the result so that equality is 1 and inequality is 0.

    where a and b are your values that you want to check for equality.
    - BartekB, a.k.a Uppernate
    Join the Click Converse Discord! - https://discord.gg/7RNXFrC
    Dungeon Raiders! - Link soon™

  9. #9
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,501
    Mentioned
    131 Post(s)
    Tagged
    0 Thread(s)
    Thanks BartekB! I definitely appreciate having fewer brackets. Many of my expressions are complicated enough already, without adding another bunch of brackets to make it even harder to follow. I love that your solution is self-contained in a single set of brackets. I'll use this formula for sure.

Similar Threads

  1. Replies: 3
    Last Post: 23rd April 2017, 06:47 PM
  2. Mathematic Equation
    By Corlen in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 17th February 2012, 06:42 PM
  3. Use the string parser to return a number?
    By MrXkill in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 29th July 2011, 04:19 PM
  4. [new ext] Quadratic Equation
    By bufferOverflow in forum Extension Development
    Replies: 10
    Last Post: 22nd June 2011, 10:47 PM
  5. Maths Equation
    By Dynamite in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 18th March 2010, 12:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •