Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. OK .. So Math Was is NOT my best subject

OK .. So Math Was is NOT my best subject

Scheduled Pinned Locked Moved Algorithms
questionhelp
12 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Rob Graham

    divide the actual output by 1000, then multiply by your variable to get the new scaled output. onew = (oold /1000) * var

    J Offline
    J Offline
    Just me at will_george something
    wrote on last edited by
    #3

    SO SORRY I voted a 1 when I should have Voted a 5! I told you I was STUPID! At first glance my brain said 1 was THE BEST.. Thank You.. DO not be to harsh on me.. I'm really a nice old man..

    T U 2 Replies Last reply
    0
    • J Just me at will_george something

      Geee. I have to ask such a simple question but I AM SURE you folks are ALOT smarter than me! Especially at math! (But I work with with my hands like a Master!) Anyway, seemed so simple untill I tried to do it.. LOL.. Lets say you have a Joystick that inputs 0 to 1000 units. I want to limit the output to some variable (To keep it simple I'll use whole numbers) to some variable such as 40, 50, 60 etc. that gives a output that is from 0 to this variable in equal units? I'm so STUPID at Math! Sorry my Left or Right brain not working for this simple problem!

      S Offline
      S Offline
      sam
      wrote on last edited by
      #4

      i think solution is in following steps 1.get the maximum value of the out put.say you get that for input 1000. it means you would want to get myMaxLimit when you get maxOP 2.so now you can use follwoing formula to limit your input desiredOP = (currentOP/maxOP)*myMaxLimit sameer

      U 1 Reply Last reply
      0
      • J Just me at will_george something

        SO SORRY I voted a 1 when I should have Voted a 5! I told you I was STUPID! At first glance my brain said 1 was THE BEST.. Thank You.. DO not be to harsh on me.. I'm really a nice old man..

        T Offline
        T Offline
        Tim Craig
        wrote on last edited by
        #5

        And if your joystick is connected to an embedded system with no hardware floating point support, you can keep everything in integer with good results by reordering the arithmetic: onew = (oold * var) / 1000 You might have to cast the old variable to the next larger type to be sure you don't overflow and then cast back.

        The evolution of the human genome is too important to be left to chance.

        U 1 Reply Last reply
        0
        • J Just me at will_george something

          Geee. I have to ask such a simple question but I AM SURE you folks are ALOT smarter than me! Especially at math! (But I work with with my hands like a Master!) Anyway, seemed so simple untill I tried to do it.. LOL.. Lets say you have a Joystick that inputs 0 to 1000 units. I want to limit the output to some variable (To keep it simple I'll use whole numbers) to some variable such as 40, 50, 60 etc. that gives a output that is from 0 to this variable in equal units? I'm so STUPID at Math! Sorry my Left or Right brain not working for this simple problem!

          R Offline
          R Offline
          Rilhas
          wrote on last edited by
          #6

          I would like to add, to the other comments psted here, that you can also do integer rounding. For example: (1456+500)/1000=1 (1677+500)/1000=2 As you can see 1456 gets rounded to 1 and 1677 gets rounded to 2. It is just like rounding floating point numbers 1.456 and 1.677. In fact, all values from 500 to 1499 will be rounded to 1, and all values from 1500 to 2499 will be rounded to 2. Rogério Rilhas

          U 1 Reply Last reply
          0
          • R Rilhas

            I would like to add, to the other comments psted here, that you can also do integer rounding. For example: (1456+500)/1000=1 (1677+500)/1000=2 As you can see 1456 gets rounded to 1 and 1677 gets rounded to 2. It is just like rounding floating point numbers 1.456 and 1.677. In fact, all values from 500 to 1499 will be rounded to 1, and all values from 1500 to 2499 will be rounded to 2. Rogério Rilhas

            U Offline
            U Offline
            User 12346520
            wrote on last edited by
            #7

            thanks: https://movied.org

            1 Reply Last reply
            0
            • R Rob Graham

              divide the actual output by 1000, then multiply by your variable to get the new scaled output. onew = (oold /1000) * var

              U Offline
              U Offline
              User 12346520
              wrote on last edited by
              #8

              thanks: https://movied.org

              1 Reply Last reply
              0
              • J Just me at will_george something

                SO SORRY I voted a 1 when I should have Voted a 5! I told you I was STUPID! At first glance my brain said 1 was THE BEST.. Thank You.. DO not be to harsh on me.. I'm really a nice old man..

                U Offline
                U Offline
                User 12346520
                wrote on last edited by
                #9

                thanks: https://movied.org

                1 Reply Last reply
                0
                • S sam

                  i think solution is in following steps 1.get the maximum value of the out put.say you get that for input 1000. it means you would want to get myMaxLimit when you get maxOP 2.so now you can use follwoing formula to limit your input desiredOP = (currentOP/maxOP)*myMaxLimit sameer

                  U Offline
                  U Offline
                  User 12346520
                  wrote on last edited by
                  #10

                  thanks: https://movied.org

                  1 Reply Last reply
                  0
                  • T Tim Craig

                    And if your joystick is connected to an embedded system with no hardware floating point support, you can keep everything in integer with good results by reordering the arithmetic: onew = (oold * var) / 1000 You might have to cast the old variable to the next larger type to be sure you don't overflow and then cast back.

                    The evolution of the human genome is too important to be left to chance.

                    U Offline
                    U Offline
                    User 12346520
                    wrote on last edited by
                    #11

                    thanks: https://movied.org

                    1 Reply Last reply
                    0
                    • J Just me at will_george something

                      Geee. I have to ask such a simple question but I AM SURE you folks are ALOT smarter than me! Especially at math! (But I work with with my hands like a Master!) Anyway, seemed so simple untill I tried to do it.. LOL.. Lets say you have a Joystick that inputs 0 to 1000 units. I want to limit the output to some variable (To keep it simple I'll use whole numbers) to some variable such as 40, 50, 60 etc. that gives a output that is from 0 to this variable in equal units? I'm so STUPID at Math! Sorry my Left or Right brain not working for this simple problem!

                      U Offline
                      U Offline
                      User 12346520
                      wrote on last edited by
                      #12

                      thanks: https://movied.org

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups