BBS: Inland Empire Archive Date: 04-23-92 (22:40) Number: 177 From: MICHAEL MALLEY Refer#: NONE To: CORIDON HENSHAW Recvd: NO Subj: Binary numbers Conf: (2) Quik_Bas
CH>In PDS, is there a way to convert BINARY numbers to DECIMAL
CH>numbers and vice-versa? (There is no BIN$ function in PDS)
DEFINT A-Z
FUNCTION Bin$ (BYVAL Value) STATIC
DIM BinString AS STRING * 16
BinString = STRING$(16, 48)
FOR Counter = 0 TO 15
IF Value AND 2 ^ Counter THEN MID$(BinString, Counter + 1) = "1"
NEXT Counter
Bin$ = BinString
END FUNCTION
This will handle words. There are probably other ways to do it more
efficiently, but this will show you the basic principle behind it.
- Michael :)
* SLMR 2.1a * If at first you don't succeed, you can always emulate me!
--- Maximus 2.01wb
* Origin: UltraTech - Nashville, TN (615) 356-0453 {HST} (1:116/30)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET