Number Base Converter One-Liner

From Bitchin100 DocGarden
Jump to navigationJump to search

Hello all-

OK, here is my attempt!

This one liner program allows you to enter and convert values <65535 from binary, decimal or hex. A universal number converter. It is possible to break it..not perfect, but it does work.

numbers/characters 0-9,A-F for number entry enter = change base backspace = zero value

enter to get things rolling

..Steve


1 V$=" "+CHR$(13)+CHR$(8)+"0123456789ABCDEF":E=INSTR(V$,INKEY$):ONEGOTO1:F=(F-(E=2))MOD3:G=9*F+2-F^2:C=-C*(E=2)-(C*G+E-4)*(E>3ANDE<G+4):PRINTMID$("BDH",F+1,1)":";:D=C:FORI=11*(F=0)-4TO0:J=G^I:X=INT(D*J):PRINTMID$(V$,X+4,1);:D=D-X/J:NEXT:PRINT:GOTO1