Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我float用来保存整数值并向其添加小位移,大约为 1 秒或 2 秒。哪个值float会停止变化?这个值的名称是什么?
float
a您获得的 IEEE 754 浮点变量的最小正值a == a+1是2^bits_precision,其中bits_precision比有效位数中的位数多 1 并且可以通过 找到std::numeric_limits<T>::digits。
a
a == a+1
2^bits_precision
bits_precision
std::numeric_limits<T>::digits
对于 32-bit float,这是 24;对于 64-bit double,这是 53(同样,在 IEEE 754 的非常常见的上下文中)。
double
演示