返回资讯中心
外部精选
软件工程
#开发者实时流

How integers should work (in systems programming languages)

I don’t like this. I’d expect { int x=a+b; int y=x-c; } to be equivalent to { int y = (a+b)-c; }. If it’s not equivalent, you’d better have a good explanation why. For example, you can say that (a+b) has a type of big i…

Hacker News 最新fanf22026/10/26 · 20 天前2 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

I don’t like this. I’d expect { int x=a+b; int y=x-c; } to be equivalent to { int y = (a+b)-c; }. If it’s not equivalent, you’d better have a good explanation why. For example, you can say that (a+b) has a type of big integer. This can work, but then you have an implicit cast from big integer to int, which is not necessarily what you always want.

The problem of the compiler optimizing the big integers out is a big one as well. The factorial example demonstrates the problem perfectly. However, you don’t have to have a primitive factorial function to have this problem. You can just write a large expression like ((abcdefg) % z) and have the same problem.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →