Someone can helpme and tell me that this program works well
Someone can helpme and tell me that this program works well
Deleted!!!
Last edited by lrcvs on Wed Apr 01, 2009 3:42 pm, edited 1 time in total.
burgr77: Try 5 decimal to binary.
Luis: ?Tal vez ser?a bueno limitar las bases a base16? Cambi? la ?ltima parte de su c?digo ?:
Luis: It might be a good idea to limit this to base 16? I changed the last part of your code to:
Luis: ?Tal vez ser?a bueno limitar las bases a base16? Cambi? la ?ltima parte de su c?digo ?:
Luis: It might be a good idea to limit this to base 16? I changed the last part of your code to:
Code: Select all
'De base 10 lo transformamos a la base destino
DO
d# = a# MOD basdes
IF d# > 10 THEN
d$ = CHR$(55 + d#)
ELSE
d$ = LTRIM$(STR$(d#))
END IF
a1$ = d$ + a1$
a# = a# \ basdes
LOOP UNTIL a# = 0
PRINT a1$
SYSTEM
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
The following Function converts any decimal Integer number (decnum&) to any base number (CBase%) up to 10 as a string number. Can be adapted to handle string entry parameters also with VAL.
Base numbers above 10 require Letter designations!
Ted
Code: Select all
FUNCTION Dec2Base$(decnum&, CBase%)
DO
remain% = decnum& MOD CBase% 'remainder sets next digit
decnum& = decnum& \ CBase% 'discard any remainder with integer division
Rnum$ = LTRIM$(STR$(remain%)) 'make base string number from remainder
Dec2Base$ = Rnum$ + Dec2Base$ 'add remainder to base number
LOOP UNTIL decnum& = 0
END FUNCTION
Ted