Imagine the hypothetical case of a custom arbitrary precision integer type that must run as fast as possible, being fully portable at the same time. To achieve this goal, we need to use the larger and faster (unsigned) integer type available for a given platform.

想象一下自定义任意精度整数类型的假设情况,它必须尽可能快地运行,同时完全可移植。为了实现这一目标,我们需要使用可用于给定平台的更大和更快(无符号)整数类型。

It must be the larger because this way we will process maximum number of bits per cycle.

它必须更大,因为这样我们将处理每个周期的最大位数。

It must be the faster because on some platforms there are available larger integer types but with only a subset of integer operations over them (for example, in x86, 128 bit integers doesn't allow to do a one-instruction add-with-carry operation).

它必须更快,因为在某些平台上有可用的更大的整数类型但只有整数运算的子集(例如,在x86中,128位整数不允许执行单指令加载 - 携带操作)。

What is the best and most portable way to obtain the larger and faster integer type on every platform that has a C99 standard compiler (if it is possible at all)?

在具有C99标准编译器的每个平台上获得更大更快的整数类型的最佳和最便携的方法是什么(如果可能的话)?

1 个解决方案

#1


2

What is the best and most portable way to obtain the larger and faster integer type on every platform that has a C99 standard compiler?

在具有C99标准编译器的每个平台上获得更大更快的整数类型的最佳和最便携的方法是什么?

Compile a test program with all candidate types, run it, time it, select the fastest and then compile your application.

使用所有候选类型编译测试程序,运行它,计时,选择最快,然后编译您的应用程序。

In other words, finding the fastest type is done at configure-time, not at compile-time. This has the additional benefit of using the fastest type even if the implementation lies about it in stdint.h.

换句话说,找到最快的类型是在配置时完成的,而不是在编译时完成的。这具有使用最快类型的额外好处,即使在stdint.h中实现它也是如此。

更多相关文章

  1. js 不同类型var的boolean运算验证
  2. 输入类型=日期的日期显示为dd-mm-yyyy格式
  3. JavaScript数据类型的一些注意点(2)
  4. javascript中的属性类型
  5. 根据AngularJS中的条件制作输入类型文件[duplicate]
  6. JS数据类型(一)
  7. javascript 数据类型转换
  8. javascript的数据类型,以及javascript中类型检测
  9. JavaScript中的类型转换(一)

随机推荐

  1. CentOS 6.5 系统 LAMP(Apache+MySQL+PHP+
  2. PostgreSQL: array 数组类型添加元素 数
  3. 为什么数据库设计人员不让标识列从最小值
  4. 注解匹配表字段与实体字段
  5. MySQL root 用户密码重置
  6. zabbix启动web界面提示:Can't connect
  7. linux时间与网络同步 // tomcat、redis、
  8. PostgreSQL操纵大对象(图片等)
  9. MySQL 插件CONNECTION_CONTROL和CONNECTI
  10. MySQL字符串相加函数如何运行?似曾相识还