Binary Routines I've Written (Public Domain) 
Author Message
 Binary Routines I've Written (Public Domain)

This is a multi-part message in MIME format.

------=_NextPart_000_01BCB971.793B3E60
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

--
Byron Smith

------=_NextPart_000_01BCB971.793B3E60
Content-Type: application/octet-stream; name="Bin$.bas"
Content-Transfer-Encoding: 7bit
Content-Description: Bin$.bas (BAS File)
Content-Disposition: attachment; filename="Bin$.bas"

DECLARE FUNCTION BINVAL& (BINAR$)
DECLARE FUNCTION BIN$ (dec&)
CLEAR
CLS
INPUT "Number: ", NUM&
PRINT BIN$(NUM&)
INPUT "Binary: ", B$
PRINT BINVAL(B$)

FUNCTION BIN$ (dec&)
  TEMP$ = ""
  FOR X% = 15 TO 0 STEP -1
    IF (dec& AND 2 ^ X%) = 2 ^ X% THEN
      TEMP$ = TEMP$ + "1"
    ELSE
      TEMP$ = TEMP$ + "0"
    END IF
  NEXT
  BIN$ = TEMP$
END FUNCTION

FUNCTION BINVAL& (BINAR$)
  TEMP& = 0
  FOR X% = 1 TO LEN(BINAR$)
    IF MID$(BINAR$, X%, 1) = "1" THEN
      TEMP& = TEMP& OR 2 ^ (LEN(BINAR$) - X%)
    END IF
  NEXT
  BINVAL& = TEMP&
END FUNCTION

------=_NextPart_000_01BCB971.793B3E60--



Tue, 22 Feb 2000 03:00:00 GMT  
 Binary Routines I've Written (Public Domain)



Thanks...

--
+?Saludos desde Mxico!+
|                      |
| .+'~~'+.             |
| * Tron *  David.BAS  |
| `+,__,+'             |
|                      |



Sun, 27 Feb 2000 03:00:00 GMT  
 Binary Routines I've Written (Public Domain)

This is a multi-part message in MIME format.

------=_NextPart_000_01BCC373.D19CC9A0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit



- See attachement "Bin$.bas"

But my routines in attachement "Bin$2.bas" are more than 20 times as fast!
Who can make them even faster?

Ewoud Dronkert
dronkert AT fys DOT ruu DOT nl

------=_NextPart_000_01BCC373.D19CC9A0
Content-Type: application/octet-stream; name="Bin$.bas"
Content-Transfer-Encoding: 7bit
Content-Description: Bin$.bas (Visual Basic Module)
Content-Disposition: attachment; filename="Bin$.bas"

DECLARE FUNCTION BIN$ (decimal&)
DECLARE FUNCTION bVAL& (binary$)

CLS

INPUT "Decimal number:", a&
PRINT BIN$(a&)
INPUT "Binary number:", b$
PRINT bVAL&(b$)

END

FUNCTION BIN$ (decimal&)

    t$ = ""

    FOR x% = 15 TO 0 STEP -1
        IF (decimal& AND 2 ^ x%) = 2 ^ x% THEN
            t$ = t$ + "1"
        ELSE
            t$ = t$ + "0"
        END IF
    NEXT
    BIN$ = t$

END FUNCTION

FUNCTION bVAL& (binary$)

    t& = 0

    FOR x% = 1 TO LEN(binary$)
        IF MID$(binary$, x%, 1) = "1" THEN
            t& = t& OR 2 ^ (LEN(binary$) - x%)
        END IF
    NEXT
    bVAL& = t&

END FUNCTION

------=_NextPart_000_01BCC373.D19CC9A0
Content-Type: application/octet-stream; name="BIN$2.BAS"
Content-Transfer-Encoding: 7bit
Content-Description: Bin$2.bas (Visual Basic Module)
Content-Disposition: attachment; filename="BIN$2.BAS"

DECLARE FUNCTION bVAL& (binary$)
DECLARE FUNCTION BIN$ (decimal&)

CLS

INPUT "Decimal number:", a&
PRINT BIN$(a&)
INPUT "Binary number:", b$
PRINT bVAL&(b$)

END

FUNCTION BIN$ (decimal&)

    x& = decimal&
    t$ = ""

    DO
        IF (x& MOD 2) <> 0 THEN
            t$ = "1" + t$
        ELSE
            t$ = "0" + t$
        END IF
        x& = x& \ 2
    LOOP UNTIL x& = 0
    BIN$ = t$

END FUNCTION

FUNCTION bVAL& (binary$)

    t& = 0

    FOR i% = 1 TO LEN(binary$)
        t& = t& * 2
        IF MID$(binary$, i%, 1) = "1" THEN
            t& = t& + 1
        END IF
    NEXT
    bVAL& = t&

END FUNCTION

------=_NextPart_000_01BCC373.D19CC9A0--



Sun, 05 Mar 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Where's Pub Domain VB Numerical Recipes routines

2. domain pruefen domain provider es domain registrieren domain angebot no domain

3. Registry question: What's the difference in writing binary data to it

4. Qbasic: Pre-written INI read/write routines?

5. domaene sichern de tc domain domain registrieren preisvergleich kostenlose toplevel domain de domain preis

6. plesk domain anmeldung domaene langsam anmeldung an domain de domain kaufen domain suchen

7. Dr GUI, I've lost my debugger and I can't get up

8. CR reports in VB4 won't update (I've tried the usual solutions)

9. I've programmed a game that don't work Help

10. Dr GUI, I've lost my debugger and I can't get up

11. Which API routine provides Win9x domain/workgroup?

12. Public domain macros?

 

 
Powered by phpBB® Forum Software