Theiling Online    Sitemap    Conlang Mailing List HQ   

Re: OT: Need help with numeric bases

From:Apollo Hogan <apollo@...>
Date:Tuesday, February 25, 2003, 5:55
On Mon, 24 Feb 2003, Nik Taylor wrote:

> Peter Clark wrote: > > Also, how does one go about converting the base of non-integer numbers? > > Division. For example, to convert, say, .125 into duodecimal, divide 1 > by 8, using a duodecimal multiplication table, so, just as the first > step in long division in decimal would be 8 divided by 10 (1), so you > divide 8 by (duodecimal) 10 to get 1 with a remainder of 4, then 8 by > (duodecimal) 40 (= decimal 48) you get 6 with a remainder of 0, so .125 > in decimal = .16 in duodecimal
One can also do it with Multiplication: to convert x to base b, just iteratively apply the following steps: (Assuming 0<=x<1 already) 1) multiply by b 2) the result will have an integer part between 0 and b-1 (inclusive); that is the next digit of your base-b rep 3) replace x with its fractional part For example, to convert 0.125 to base 7, we get: rep x x*7 0. 0.125 0.875 0.0.. 0.875 6.125 0.06.. 0.125 0.875 etc. Here we get a repeat already, so we see that 0.125 (base 10) is written as 0.0606060606... in base 7. A more interesting example, write PI in base 12: (We first strip off the integer part 3) rep x x*12 3. 0.1415926.. 1.69911184.. 3.1 0.69911184.. 8.38934211.. 3.18 0.38934211.. 4.67210540.. 3.184 0.67210540.. 8.06526483.. 3.1848 etc. ad nauseum; hence PI = 3.1848... in base 12. Cheers, --Apollo

Replies

Nik Taylor <yonjuuni@...>
John Cowan <cowan@...>