Change numeric system - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Projects (http://qbasicnews.com/newforum/forum-12.html) +--- Thread: Change numeric system (/thread-10153.html) |
Change numeric system - lrcvs - 08-19-2008 Hello everyone: Someone can tell me that this program works well sometimes and other sometimes bad? Example 1: Decimal >> Binary Example 2: Base 6 >> Base 25 Example 3: Base 10 >> Base 4 'Este programa transforma un numero entre sistemas numericos distintos 'Peligro, no funciona bien siempre, sobre todo con base 2. ??? CLS INPUT "Number to transform : "; numorg INPUT "Base init : "; basorg INPUT "Base end "; basdes 'Aqui transformamos el numero a base 10 a$ = LTRIM$(STR$(numorg)) c = LEN(a$) FOR d = c - 1 TO 1 STEP -1 e$ = MID$(a$, d, 1) x# = x# + (VAL(e$) * (basorg ^ (c - d))) NEXT d e$ = MID$(a$, c, 1) x# = x# + (VAL(e$) * 1) a# = x# d = 0 'De base 10 lo transformamos a la base destino DO c# = a# / basdes d# = a# MOD basdes a1$ = a1$ + LTRIM$(STR$(d#)) IF c# <> 1 THEN a# = INT(c#) LOOP UNTIL a# <= basdes a1$ = a1$ + LTRIM$(STR$(INT(c#))) g = LEN(a1$) FOR f = g TO 1 STEP -1 c$ = MID$(a1$, f, 1) b$ = b$ + c$ NEXT f PRINT b$ END Re: Someone can helpme and tell me that this program works well sometimes? - Ralph - 08-19-2008 Luis: It is not considered good form to post the same question in more than one site at a time. Several of us have already answered you in Pete's QuickBASIC Site. Luis: No está bien considerado el poner la misma pregunta en más de un sitio a la vez. Ya varios le hemos contestado en Peteâs QuickBASIC Site. The program is correct ... - lrcvs - 08-19-2008 The program is correct: http://www.petesqbsite.com/forum/viewtopic.php?t=2746 Thanks |