def Compact3D_21bit(x):
    """
    Decodes the 64 bit morton code into a 21 bit number in the 3D space  using
    a divide and conquer approach for separating the bits. 
    
    Args:
        x (int): a 64 bit morton code
        
    Returns:
        int: a dimension in 3D space
        
    Raises:
        Exception: ERROR: Morton code is always positive
    """

    if x < 0:
        raise Exception("""ERROR: Morton code is always positive""")
    x &= 0x1249249249249249
    x = (x ^ (x >> 2)) & 0x30c30c30c30c30c3
    x = (x ^ (x >> 4)) & 0x700f00f00f00f00f
    x = (x ^ (x >> 8)) & 0x00ff0000ff0000ff
    x = (x ^ (x >> 16)) & 0x7fff00000000ffff
    x = (x ^ (x >> 32)) & 0x00000000ffffffff
    return x