Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

step-2 xc-tutor.c 中关于数字处理的问题 #2

Closed
ghost opened this issue Feb 14, 2016 · 1 comment
Closed

step-2 xc-tutor.c 中关于数字处理的问题 #2

ghost opened this issue Feb 14, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 14, 2016

代码第87-113.

代码中的逻辑是这样的:

token_val = token - '0';
 if (token_val) {
   //hex
    if (*src == 'x' || *src == 'X') {

    }else{
  // dec
    }
}
else
{
//oct
}

我觉得逻辑应该是这样的,调换一下dec和oct的代码位置:

token_val = token - '0';
 if (token_val) {
   //hex
    if (*src == 'x' || *src == 'X') {

    }else{
  // oct
    }
}
else
{
//dec
}

github上这样写对十六进制和八进制是没有影响的,作者只测试了十进制,所以没发现吧,把hello.c 中的数字换成十六进制一试便知。请lotabout再看一眼git上的代码吧。

@lotabout
Copy link
Owner

Hi,

你的代码是正确的,我的确只测试了十进制。在博客里有评论指出了这点,我也做了相应的修改。

只是当时只修改到 master 分支上。现在也修改到了其它的 step 分支上了。对你造成了不便,十分抱歉。

P.S. 在 Github 上贴代码可以用 markdown 的代码块,这样不会有格式的问题,同时还有高亮。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant