Advertisement
LBASIC

2BINARY$.BAS

Jun 5th, 2023
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 0.30 KB | Source Code | 0 0
  1. DECLARE FUNCTION BINARY$ (ToBin&)
  2. INPUT "Enter a number to represent in binary"; number&
  3. PRINT BINARY$(number&); " ="; number&
  4.  
  5. FUNCTION BINARY$ (ToBin&)
  6.    result$ = ""
  7.    FOR bit% = 0 TO 15
  8.       result$ = CHR$(48 - ((ToBin& AND (2 ^ bit%)) <> 0)) + result$
  9.    NEXT
  10.    BINARY$ = result$
  11. END FUNCTION
Tags: binary qbasic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement