[Memo] Java의 >>> 연산자와 <<< 연산자를 C#으로 옮긴다면 이렇습니다.
Software Development/Useful Solutions 2010/07/22 20:24Java로 작성된 코드를 C#으로 옮길 필요가 있어 살펴보던 중 눈에 익숙하지 않은 Java 고유의 Bitwise Shift 연산자를 발견했습니다. Triple Shift Operator를 어떤 의미로 해석해야 가장 정확할지 확실히 알 수 없어서 인터넷을 검색하던 중 저와 같은 고민을 하는 개발자의 질문이 역시 stackoverflow.com에 있었고 명쾌한 해답을 얻을 수 있었습니다. :-)
질문: What is the equivalent (in C#) of Java's >>> operator? Just to clarify, I'm not referring to the >> and << operators.
답변: In C#, you can use unsigned integer types, and then the<<and>>do what you expect. The MSDN documentation on shift operators gives you the details. Since Java doesn't support unsigned integers (apart fromchar), this additional operator became necessary.
위의 질문과 답변 내용에 입각하여 코드를 작성한다면 아래와 같습니다.
/* Java Code */
int x = 3;
int y = x >>> 3;
/* Equivalent C# Code */
int x = 3;
int y = (int)((uint)x >> 3);
Java에는 C#과는 달리 Unsigned Integer Type이 따로 정의된 것이 없기 때문에 이와 같은 특수한 연산자를 하나 더 정의하게 된 것이라는 설명도 스레드 하단부에서 찾을 수 있었습니다.
자료 출처: http://stackoverflow.com/questions/1880172/equivalent-of-java-triple-shift-operators-and-in-c
'Software Development > Useful Solutions' 카테고리의 다른 글
| Internet Explorer 9 설치에 문제가 있으신가요? (0) | 2010/09/16 |
|---|---|
| Introducing Visual Studio LightSwitch! - Enjoy your development (0) | 2010/08/05 |
| [Memo] Java의 >>> 연산자와 <<< 연산자를 C#으로 옮긴다면 이렇습니다. (0) | 2010/07/22 |
| [필독] Visual Studio 2010과 Crystal Report (0) | 2010/07/15 |
| Microsoft 제품군 관련 MIME Type 목록 (0) | 2010/06/08 |
| Visual Studio 2010 RC 패치 (KB980610)가 발표되었습니다. (0) | 2010/03/09 |