Пример #1
0
def getChampernowneConstant( ):
    '''This function creates the Champernowne constant for the input base.'''
    result = ''

    count = 1

    while len( result ) <= mp.dps:
        result += convertToBaseN( count, g.inputRadix )
        count += 1

    return convertToBase10( '0', result, g.inputRadix )
Пример #2
0
def convertLatLongToNAC( args ):
    if isinstance( args, RPNGenerator ):
        return convertLatLongToNAC( list( args ) )
    elif not isinstance( args, list ):
        args = [ args, 0 ]
    elif args and isinstance( args[ 0 ], list ):
        return [ convertLatLongToNAC( i ) for i in args ]
    elif len( args ) == 1:
        args.append( 0 )

    numerals = '0123456789BCDFGHJKLMNPQRSTVWXZ'

    if args[ 0 ] > 90.0 or args[ 0 ] < -90.0:
        raise ValueError( '\'natural_area_code\' requires a latitude parameter of -90 to 90' )

    if args[ 1 ] > 180.0 or args[ 1 ] < -180.0:
        raise ValueError( '\'natural_area_code\' requires a longitutde parameter of -180 to 180' )

    lat = fdiv( fadd( args[ 0 ], 90 ), 180 ) * 729000000
    long = fdiv( fadd( args[ 1 ], 180 ), 360 ) * 729000000   # 30 ** 6

    return convertToBaseN( long, 30, False, numerals ) + ' ' + convertToBaseN( lat, 30, False, numerals )