to divide a number by 128 without using division operator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karthikeyan2494
    New Member
    • Mar 2013
    • 1

    to divide a number by 128 without using division operator

    Question about instead of using the division operator to display the output of user"s input
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You can use a bit shift but it will only work on integers and it won't have the decimal portion. So the answer won't be accurate.

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      homework question?
      Are exponents and multiplication out of the question?
      That's my only thought and how I solved almost the same question some 20+ years ago... different number though so the bit-shift didn't even dawn on me!

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Did you try subtracting 128 inside a loop thst counts the number of cycles?

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #5
          WFC: Now that's cheating! ;-)

          Comment

          Working...