[Math] Fractional number bases

number-systems

I have a student doing any investigation in to fractional number bases.
For example 10 in base (3/2) would be 2101.
We can do it manually but to generate enough data to investigate any patterns and other fractional number bases would anybody know how to automate generating the data in Excel, Python or an online applet?

Best Answer

I don't think you need to generate much data to realize the problem with fractional number bases. Consider base $2.5$, illustrated here. Just by looking at the top diagram we can see that '$0.22$'$ > 1$. The number line is useful to us because it allows us to measure quantities - we divide it into units and then repeatedly subdivide each of them. Whereas the first division of unity in base $2.5$ yields $0.4$, the second yields $0.16$. Two of these latter subdivisions are greater than the 'resolution' of $2.5$ (i.e. half in base $2.5$, or $0.2$ in base $10$) so it doesn't necessarily help us attain finer resolution. Why not just use the resolution of $2.5$ as a subunit? This gives us base $5$, and as can be seen from the lower diagram multiples of second subdivisions will not 'spill over' to confuse our understanding of what 'number one' actually means (because by definition there can't be enough of them). See here for the formal proofs of these concepts.

EDIT1 This answer follows on from this reddit discussion. User Brightlinger claims that the above problem leads to non-unique representations for numbers in fractional bases and gives the example of $4$ in base $π$ (this is 'fractional' as in 'not an integer').

EDIT2 The following Python3 script allows a number to be represented in a chosen base. Both the number and the base can have decimal parts:

# fracbase.py
import sys, math

target = float(sys.argv[1])
base = float(sys.argv[2])


def decomp(tarnum, nbase):
    if nbase <= 1:
        return 'ERROR Base must be > 1'
    print('\nRepresenting', tarnum, 'in base', nbase, ' Log is', math.log(tarnum, nbase), '\n')
    powr = int(math.log(tarnum, nbase)) 
    rep = []
    while powr > -13:
        tnratio = tarnum / nbase**powr      
        rep.append(int(tnratio))  
        print('There are', tnratio, nbase, 'to the power of', powr, 'in', tarnum, 'so', rep)
        tarnum -= int(tnratio) * nbase**powr
        if tarnum == 0:
            if powr > 0:
                for i in range(powr):
                    rep.append(0)
            return rep
        if powr == 0:
            rep.append('.')
        powr -= 1        
    return rep


print(decomp(target, base))

Example session:
chrx@chrx:[tilde]/Desktop$ python3 fracbase.py 1001 10.4
The [tilde] means the tilde character.