Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!wuee1!jtw From: jtw@wuee1.wustl.edu (Trent Wohlschlaeger) Newsgroups: comp.lang.pascal Subject: Re: Brain Teaser Message-ID: <1989Oct5.213548.13466@wuee1.wustl.edu> Date: 5 Oct 89 21:35:48 GMT References: <727@thor.wright.EDU> Sender: news@wuee1.wustl.edu (USENET News System) Reply-To: jtw@wuee1.UUCP (Trent Wohlschlaeger) Organization: Washington University, St. Louis, MO Lines: 20 In article <727@thor.wright.EDU> demon@thor.wright.edu writes: > Write a routine that will convert from one base to another. >function convert(base : integer; input_num : string) : string; ^^^^ This is a fairly standard "problem." However, I think your definition is under-determined. Is 'base' the current base of the number, or the base to which it is to be converted? Might I suggest: function convert(inbase, outbase : integer; input_num : string) : string; I would be more impressed with code that does this directly, rather than converting to base 10 (or 2, or 16, or...) first. For example, convert 10110101 base 4 to x base 7. x:= convert (4, 7, "10110101"); Trent