At 07:54 PM 3/16/98 -0600, you wrote: >Hello Mike, > >I, for one, would very much like to see your program. Can you post it >here? I don't know if I have any insights, but I don't think anyone will >take any pot shots at you for "poor programming." If it works, it is >better than what I have done on the topic :-) > This procedure's been hanging around for a number of years. It's real handy for converting numbers from one base to another...2, 3, 10, or whatever. It runs in a variety of Logo dialects. Haven't tried it in MicroWorlds yet. TO ANYBASE.TO.DEC :N :BASE :POWER IF EMPTYP :N [OP 0] OP (:POWER * C.TO.N LAST :N) + ANYBASE.TO.DEC BL :N :BASE :POWER * :BASE END TO C.TO.N :N IF NUMBERP :N [OP :N] OP (ASCII :N) - 55 END TO CONVERT :N :FRBASE :TOBASE OP DEC.TO.ANYBASE ANYBASE.TO.DEC :N :FRBASE 1 :TOBASE END TO DEC.TO.ANYBASE :N :BASE IF :N < :BASE [OP N.TO.C :N] OP WORD DEC.TO.ANYBASE INT QUOTIENT :N :BASE :BASE N.TO.C REMAINDER :N :BASE END TO DIVISORP :A :B OP 0 = REMAINDER :B :A END TO INFO ; CHAPTER 10 THE GREAT MATH ADVENTURE ; CONVERTING NUMBERS ; TYPE CONVERT, A NUMBER, FROM BASE <number>, TO BASE <number>. ; TRY SHOW CONVERT 15 10 2 ;; PR [SEE THE INFO PROCEDURE FOR MORE INFORMATION.] END TO N.TO.C :N IF :N < 10 [OP :N] OP CHAR 55 + :N END Regards...Jim Muller >+>+>+>+>+>+>+>+>+>+>+>+>+>+>+> Jim Muller jmul@cyberramp.net The Great Logo Adventure at http://www.cyberramp.net/~jmul >+>+>+>+>+>+>+>+>+>+>+>+>+>+>+> --------------------------------------------------------------- Please post messages to the Logo forum to logo-l@gsn.org. Mail questions about the list administration to logofdn@gsn.org. To unsubscribe send unsubscribe logo-l to majordomo@gsn.org.
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home