src/dlt/randomizer_utils.py
def cobol_hash(SSN: int) -> float:
    """
    A python implementation of COBOL's fixed-point arithmetic
    """
    with localcontext() as ctx:
        # Constants determined by DoIT
        ctx.prec = 10
        ctx.rounding = decimal.ROUND_DOWN

        L_SD = Decimal(SSN)
        C_A = Decimal("0000016807")
        C_M = Decimal("2147483647")
        C_Q = Decimal("0000127773")
        C_R = Decimal("0000002836")

        # Translated
        W_HI = (L_SD / C_Q).quantize(Decimal("1E0"))  # L_SD // C_Q
        W_LO = L_SD - C_Q * W_HI  # L_SD % C_Q
        L_SD = C_A * W_LO - C_R * W_HI

        if L_SD <= 0:
            L_SD += C_M
        L_RAND = (L_SD / C_M).quantize(Decimal("1E-10"))

        if L_RAND == 0:
            warnings.warn("L_RAND is zero")
            L_SD += C_M

        return L_RAND

    A python implementation of COBOL's fixed-point arithmetic
    
A python implementation of COBOL's fixed-point arithmetic
A python implementation of COBOL ' s fixed - point arithmetic
def cobol_hash(SSN: int) -> float:
    with localcontext() as ctx:
        ctx.prec = 10
        ctx.rounding = decimal.ROUND_DOWN
        L_SD = Decimal(SSN)
        C_A = Decimal("0000016807")
        C_M = Decimal("2147483647")
        C_Q = Decimal("0000127773")
        C_R = Decimal("0000002836")
        W_HI = (L_SD / C_Q).quantize(Decimal("1E0"))  
        W_LO = L_SD - C_Q * W_HI  
        L_SD = C_A * W_LO - C_R * W_HI
        if L_SD <= 0:
            L_SD += C_M
        L_RAND = (L_SD / C_M).quantize(Decimal("1E-10"))
        if L_RAND == 0:
            warnings.warn("L_RAND is zero")
            L_SD += C_M
        return L_RAND
def cobol_hash ( SSN : int ) -> float : with localcontext ( ) as ctx : ctx . prec = 10 ctx . rounding = decimal . ROUND_DOWN L_SD = Decimal ( SSN ) C_A = Decimal ( "0000016807" ) C_M = Decimal ( "2147483647" ) C_Q = Decimal ( "0000127773" ) C_R = Decimal ( "0000002836" ) W_HI = ( L_SD / C_Q ) . quantize ( Decimal ( "1E0" ) ) W_LO = L_SD - C_Q * W_HI L_SD = C_A * W_LO - C_R * W_HI if L_SD <= 0 : L_SD += C_M L_RAND = ( L_SD / C_M ) . quantize ( Decimal ( "1E-10" ) ) if L_RAND == 0 : warnings . warn ( "L_RAND is zero" ) L_SD += C_M return L_RAND
A python implementation of COBOL's fixed-point arithmetic
A python implementation of COBOL ' s fixed - point arithmetic
"""
    A python implementation of COBOL's fixed-point arithmetic
    """ # Constants determined by DoIT # Translated # L_SD // C_Q # L_SD % C_Q
SSN
int