Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Binary... Say what?
#1
Make a qbasic program that convert words/ letters into binary.
I should be able to enter Joe and it comes out:

J = 00001010
O = 00001111
E = 00000101


Oh... and also... ABC = 123
So "J" = 10

Have fun!

Also... I have one that works... It's not perfect though.
BTW: No LIBs

EDIT: If you need help or don't know what binary is... PM me and ill explain it best as i can
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#2
Here's my one:

Code:
DECLARE FUNCTION Dec2Bin$ (Dec%)
DECLARE FUNCTION Word2Bin$ (Word$)

PRINT Word2Bin$("Hello")

FUNCTION Dec2Bin$ (Dec%)
Bin$ = ""
DO
  Bin$ = LTRIM$(STR$(Dec% MOD 2)) + Bin$
  Dec% = INT(Dec% / 2)
  IF Dec% = 0 THEN EXIT DO
LOOP
IF LEN(Bin$) < 8 THEN Bin$ = STRING$(8 - LEN(Bin$), "0") + Bin$
Dec2Bin$ = Bin$
END FUNCTION

FUNCTION Word2Bin$ (Word$)
Bin$ = ""
FOR n% = 1 TO LEN(Word$)
  Bin$ = Bin$ + Dec2Bin$(ASC(MID$(Word$, n%, 1)) - 64)
NEXT n%
Word2Bin$ = Bin$
END FUNCTION

It's a 3-Minutes-Work
B 4 EVER
Reply
#3
I think I may have my old program somewhere..... nope, I guess I must have deleted it. It would change .txt files into hex or binary. Quite cool. sorry I couldn't find it.
am an asshole. Get used to it.
Reply
#4
ak00ma... Nice but not what i asked for...
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#5
This one maybe:

Code:
DECLARE FUNCTION Dec2Bin$ (Dec%)
DECLARE Sub Word2Bin (Word$)

Input Word$
Word2Bin(Word$)

FUNCTION Dec2Bin$ (Dec%)
Bin$ = ""
DO
  Bin$ = LTRIM$(STR$(Dec% MOD 2)) + Bin$
  Dec% = INT(Dec% / 2)
  IF Dec% = 0 THEN EXIT DO
LOOP
IF LEN(Bin$) < 8 THEN Bin$ = STRING$(8 - LEN(Bin$), "0") + Bin$
Dec2Bin$ = Bin$
END FUNCTION

SUB Word2Bin (Word$)
Bin$ = ""
FOR n% = 1 TO LEN(Word$)
  PRINT MID$(Word$, n%, 1) + "=" + Dec2Bin$(ASC(MID$(Word$, n%, 1)) - 64)
NEXT n%
END SUB
B 4 EVER
Reply
#6
Even closer... but I want to inout a word... and also...

I want to be able to unout Joe
and it prints out

J = 00001010
O = 00001111
E = 00000101

Your missing something
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#7
Code:
input word$
print "J = 00001010"
print "O = 00001111"
print "E = 00000101"

:rotfl:

i think the goal of this program have been done time and again.

Code:
input word$
for y% = 1 to len(word$)
  value% = asc(mid$(word$, y%, 1))
  binary$ = ""
  for x% = 0 to 7
    if value% and 1 then binary$ = "1" + binary$ else binary$ = "0" + binary$
    value% = value% \ 2
  next x%
  print ucase$(MID$(word$, y%, 1)); " = "; binary$
next y%
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#8
toonski84: Not quite... Didn't print out the letter.

ak00ma: Yours didn't print out the CAPITAL letter
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#9
printed it out for me...

edit: oh, you want the capital letter? (anal-retentive bastard...) :lol:
edit: there... you have your capital letter! now be happy! *throws a screaming fit!*
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#10
What... you didn't pay attention
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)