トピック
KuroHana elijahpwg

How would I make a number to binary converter? I know binary, and normal numbers (Obviously). Would I just make like...

INPUT "Type a number"; NO IF NO==1 THEN PRINT"1=0001" etc. ... Or is there an easier way?
0そうだね
プレイ済み
返信[1]
親投稿
Hanzo rzsense
Please refer to the following codes. CLS:INPUT"Type a number";NO FOR I=31 TO 0 STEP -1 IF(NO AND(&H1<<I))!=0 THEN ?"1"; ELSE ?"0"; NEXT I ? END
1そうだね
未プレイ
返信[2]
親投稿
KuroHana elijahpwg
SYNTAX ERROR 0:4 ELSE ?"0"; Doesnt work
0そうだね
プレイ済み
返信[3]
親投稿
Hanzo rzsense
You have to write "IF ... THEN ... ELSE ..." in one line.
0そうだね
未プレイ
返信[4]
親投稿
KuroHana elijahpwg
There is alot of zeros but can I remove them
0そうだね
プレイ済み
返信[5]
親投稿
Hanzo rzsense
Of course you can. Please write (binary digit - 1) instead of "31" in line 2. For example, you'll get 4 digit binary, you should write "FOR I=3..." in line 2.
0そうだね
未プレイ
返信[6]
親投稿
L. Lohadaa
Coding's an art and everyone's slightly different. I like Hanzo's way of thinking. Here's mine. The trick is to keep dividing by 2 until it's gonna be less than 1, then stop and print the remainders. This way no leading zeroes will appear.
1そうだね
プレイ済み
返信[7]
親投稿
KuroHana elijahpwg
Cool
1そうだね
プレイ済み