투케이2K

212. (swift5/xcode) [유틸 파일] numberEncodeFormatString : 10 진수 값을 특정 진법 값으로 변환 수행 본문

Swift

212. (swift5/xcode) [유틸 파일] numberEncodeFormatString : 10 진수 값을 특정 진법 값으로 변환 수행

투케이2K 2024. 5. 3. 20:23
반응형

[개발 환경 설정]

개발 툴 : XCODE

개발 언어 : SWIFT5

 

[소스 코드]

    // -----------------------------------------------------------------------------------------
    // MARK: - [10 진수 값을 특정 진법 값으로 변환 수행 실시]
    // -----------------------------------------------------------------------------------------
    func numberEncodeFormatString(type: Int, data: Int) -> String {
        
        /*
        // -----------------------------------------
        [numberEncodeFormatString 메소드 설명]
        // -----------------------------------------
        1. 10 진수 값을 특정 진법 값으로 변환 수행 실시
        // -----------------------------------------
        2. 호출 방법 : C_Encryption().numberEncodeFormatString(type: 2, data: 10)
        // -----------------------------------------
        3. 리턴 반환 : 1010
        // -----------------------------------------
        */
        
        // [초기 리턴 데이터 변수 선언 실시]
        var returnData = ""
        
        // [인풋 데이터 조건 체크 수행 실시]
        if type == 2 || type == 8 || type == 16 {
            
            returnData = String(data, radix: type)
            
        }
        
        // [로그 출력 실시]
        S_Log._D_(description: "10 진수 값을 특정 진법 값으로 변환 수행 실시", data: [
            "INPUT [TYPE] :: \(type)",
            "INPUT [DATA] :: \(data)",
            "RETURN :: \(returnData)"
        ])
        
        // [리턴 데이터 반환 실시]
        return returnData
    }
 

[결과 출력]

 

 

반응형
Comments