여러코드를 코드를 보다보면 이렇게도 응용을 할수 있구나라는 생각이든다.
과연 그 코드를 모르는 상태에서 이러한 코드를 생성할수 있을까...
/*10진수를 16진수로 출력하는 프로그램*/
#include <stdio.h>
void main()
{
int input;
int low, hi;
while(1)
{
printf("0~255사이의 수를 입력하시오: ");
scanf("%d", &input);
hi = input >> 4;
low = input & 0xf;
printf("입력한 수의 16진 표기 = %c%c\n", hi+'0'+(hi > 9)*7, low+'0'+(low > 9)*7);
}
}
10진에서 16진수를 구하기 위해 상위비트는 비트연산자를 통해 구하고
하위비트는 논리연산자로 마스크(?)를 만들어서 변수에 저장 시켰다.
그리고 나서 이를 16진수로 바꾸기 위해서 0의 아스키코드값 48과 더하면 9를 초과하는지의
여부를 알 수 있다. (hi >9)가 참이면 1 아니면 0을 리턴하는 것을 응용하여 9를 초과 했다면
아스키코드값이 대문자 A가 부터 표현하기 위해 7을 더해준다. (브라보!)
댓글을 달아 주세요
hex 값 표현 하는 부분을 정말 많이 고민했었는데 이렇게 쉽게 풀리네요!
좋은 자료 감사합니다~
Ӏ think what yoou published made a bunch of sеnse.However, whuat about this?
ssuppose уou added a little infߋгmation? I mean, I don't wat to tell you howw to rᥙn y᧐ur website, but wha
if you added a post title that makes peole desire
moгe? I mean 지나간 삶 :: 3.15(목) 비트연산자 활용,
16진수구하기 iis a lttle vanilⅼɑ.Yоu could peek at Ⲩahoo's ront
page and see how thеy create article headlines to
get viewers to click. You might try adding a video oߋr a гelated
ppic or two to grab readеrs interested about
everүthing've written. Just my opіnion, it might make your ԝebsite
a lіttle biіt more interesting.
WOW just what I was searching for. Came here by
searching for 강서구출장마사지
Yes! Finally someone writes about 초읍출장마사지.
Thanks for finally talking about >지나간 삶 :: 3.15(목) 비트연산자 활용,16진수구하기 <Liked it!
Thanks for finally writing about >지나간 삶 :: 3.15(목) 비트연산자 활용,
16진수구하기 <Loved it!
I believe what you said made a great deal of sense. However, think on this, what if you added
a little content? I ain't saying your information isn't good.,
but what if you added a post title that makes people desire more?
I mean 지나간 삶 :: 3.15(목) 비트연산자 활용,16진수구하기
is a little vanilla. You ought to look at Yahoo's front page and watch how they create news
headlines to grab viewers to open the links. You might add a video or a related pic
or two to grab people interested about everything've written.
Just my opinion, it could bring your blog a
little bit more interesting.
WOW just what I was looking for. Came here by searching
for 안양출장마사지
Thanks for finally writing about >지나간 삶 :: 3.15(목) 비트연산자 활용,16진수구하기 <Liked it!
Thanks for finally talking about >지나간 삶 :: 3.15(목) 비트연산자 활용,16진수구하기 <Loved it!
I believe everything posted made a great
deal of sense. However, what about this? suppose you wrote a catchier
post title? I am not saying your content isn't good., however what if you added something that grabbed people's attention? I mean 지나간 삶 ::
3.15(목) 비트연산자 활용,16진수구하기 is a little
vanilla. You should look at Yahoo's front page and see how they write news titles to grab
viewers to click. You might try adding a video or
a pic or two to get people interested about what you've got to say.
Just my opinion, it could bring your blog a little livelier.
I think everything said was very logical. However, think on this, what if you were to write a awesome title?
I am not suggesting your content is not solid., however what if you added a headline that grabbed folk's attention? I mean 지나간 삶 :: 3.15(목)
비트연산자 활용,16진수구하기 is kinda plain. You ought to peek at Yahoo's front
page and watch how they create news headlines to get viewers interested.
You might add a related video or a pic or two to grab readers interested about everything've got to say.
Just my opinion, it could bring your posts a little livelier.
WOW just what I was searching for. Came here by searching for 강서구출장안마
WOW just what I was searching for. Came here by searching for 용원출장
Ꭲhankѕ for finaⅼly talking about >지나간 삶 :: 3.15(목) 비트연산자 활용,16진수구하기 <Liked it!