Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    bitGet problem

    Beginners
    6
    24
    889
    Loading More Posts
    • 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.
    • pianofire
      pianofire Fuze Team last edited by

      For the OCR code generator I have a couple of user functions:

      // convert a decimal number to a binary string
      function dec2bin(n,length_type)
        string byte=""
        if length_type > 0  then
          while int(n) > 0 loop
             nbit =  (n % 2)
             byte = str(nbit) + byte    
             n = n / 2
          repeat
          //pad to length_type bits...
          while len(byte) < length_type loop
            byte = "0" + byte
          repeat
        endif
      return byte
      
      // convert a binary string to decimal
      function bin2dec( binaryString )
        int result = 0
        int i = 0
        for i = 0 to len( binaryString ) loop
          result *= 2
          result += int( binaryString[ i ] )
        repeat
      return result
      

      Credit to @faz808 for the first one

      1 Reply Last reply Reply Quote 2
      • xevdev
        xevdev F last edited by

        Thanks but

        I simply want a binary number to be visible in my program that way I can easily change the bits

        1 Reply Last reply Reply Quote 0
        • pianofire
          pianofire Fuze Team last edited by

          As far as I know there is no way to that currently

          1 Reply Last reply Reply Quote 0
          • xevdev
            xevdev F last edited by

            That's ok the above works in a roundabout way

            1 Reply Last reply Reply Quote 0
            • First post
              Last post