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.
    • PB____
      PB____ last edited by

      Pianofire beat me to it :P

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

        You are right the documentation isn't very clear but it seems to start at the least significant bit with a start index of 0

        1 Reply Last reply Reply Quote 1
        • PB____
          PB____ last edited by

          Seems to be so. In the end all the necessary information is actually there (and the example code shows that bit 0 is used to decide if the number is even or odd), but you need to process all the information to get to it :)

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

            Of course !
            In my example,
            bit 0 = 1
            bit 1 = 0
            bit 2 = 0
            bit 3 = 0
            bit 4 = 1

            I forgot to convert my required binary number ( 11111111) to hex..

            result = bitGet (0xff, 3)
            drawtext (33,333,32, white, result)
            result = 1 asv expected

            Brain now in gear. Thanks for the help.

            1 Reply Last reply Reply Quote 1
            • SteveZX81
              SteveZX81 F last edited by SteveZX81

              I'm wondering how this is "beginners". (not complaining btw)
              Must mean I'm in the ultra beginners category ;)

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

                Well you can be an experienced programmer but still a beginner at Fuze

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

                  Very true, ..facepalm..

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

                    Is there any way to actually use a binary number in fuze without converting it.

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

                      @xevdev I think it depends what you are trying to do if you want to replace your code by binary coding i dont think that works in fuze

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

                        I'm not sure what you mean by us a binary number in this case?

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

                          @petermeisenstein in this question they used a hexadecimal number ( base 16 ) by putting an x in a number as in 0x000001 giving 1 in decimal ( base 10 ) so I was wondering if I put some other letter , I've used % in other languages , to denote that it's a binary number ( base 2 )

                          P 1 Reply Last reply Reply Quote 1
                          • P
                            petermeisenstein F @xevdev last edited by

                            @xevdev So i am not good at maths so I am sorry for any wrong thing what I say now. Isnt % the modulo I dont know if you say modulo in english.

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

                              @petermeisenstein yes in fuze it is and I wrote my own mod function because I was expecting a function name not a symbol . So each language is different .

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

                                @xevdev
                                And you are dealing with binary stuff in fuze very cool. Back to the roots of codeing

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

                                  @petermeisenstein not if there's no way to put a binary number in to my code so I'll use
                                  Bin = "10110010"
                                  If bin [0] = "1" then print("true")
                                  And because the first digit is 1 it will print true
                                  I think ?
                                  Got caught out again use
                                  If bin [0] ==
                                  Double equals

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

                                    @xevdev Yeah I would also say maybe it helps you there is strcontains and other string stuff in fuze. Are you programming a ROM for a cpu emulator ?

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

                                      No I just want a binary number to use as a bitmask
                                      And the code above doesn't work which is funny because I just wrote a whole program which uses something similar to that.

                                      1 Reply Last reply Reply Quote 0
                                      • 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
                                            • First post
                                              Last post