QB64.org Forum
Active Forums => Programs => Topic started by: NOVARSEG on January 05, 2021, 01:49:45 am
-
Got the idea from other post that used the MOD operator. STxAxTIC
Ok removed some bugs. might add features later.
Will post a base 10 to hexadecimal (base 16) convertor as well. Got the code working but want to double check it.
It turns out that it is possible to convert anywhere from base 2 to base 16 and maybe above that but base 16 is kinda standard.
t = ""
INPUT "Enter a base 10 number"; m
INPUT "Convert to what base? 2 to 9 "; b
n = m
n = n - r
n = n / b
PRINT "Base 10 number = "; m
PRINT "converted to base"; b;
"= "; t
-
Converts base 10 number to any base from 2 to 16
t = ""
INPUT "Enter a base 10 number"; m
INPUT "Convert to what base? 2 to 16 "; b
n = m
n = n - r
n = n / b
PRINT "Base 10 number = "; m
PRINT "converted to base"; b;
"= "; t
-
Have you considered extending this through decimals?
I have tried binary and drew some interesting designs when I changed 0, 1's to black and white blocks then stacked (0 to m-1) / m (rational numbers) on top of each other.
1/m = black and white boxes like a bar code
2/m = ...
3/m
.
.
.
m-1/m
-
Some minor bugs
wrong variable type - fixed
Can now convert from base 2 to base 36
t = ""
INPUT "Enter a base 10 number"; m
INPUT "Convert to what base? 2 to 36 "; b
n = m
n = n - r
n = n / b
PRINT "Base 10 number = "; m
PRINT "converted to base"; b;
"= "; t
-
I just re-checked this thread. Nice job folks.
bplus - have you considered putting all your stuff together in one place, or are you satisfied with writing your words in water?
You need a website and flashy github right now.