简体   繁体   English

商上的加速C ++

[英]Accelerated C++ on quotients

I am reading the book "Accelerated C++". 我正在读《加速C ++》这本书。 In the details of chapter 2, a description of division between two numbers and extracting their quotient is provided: 在第2章的详细信息中,提供了两个数字之间的除法并提取其商的描述:

x / y x / y

Quotient of x and y . x和y的商。 If both operands are integers, the implementation chooses whether to round toward zero or - 8 如果两个操作数都是整数,则实现选择是四舍五入为零还是-8

I don't understand this one. 我不明白这一点。 What does "round toward [...] - 8" mean? “朝[...]-8进位”是什么意思? What implementations use that and why? 哪些实现使用它,为什么?

Well I tried searching for that but didn't find anything. 好吧,我尝试搜索,但是什么也没找到。

The book probably means round towards negative infinity , ie -∞: 这本书可能意味着朝负无穷大方向舍入 ,即-∞:

Directed roundings 有向四舍五入

  • Round toward 0 – directed rounding towards zero (also known as truncation). 向0舍入–向0定向舍入(也称为截断)。
  • Round toward +∞ – directed rounding towards positive infinity (also known as rounding up or ceiling). 向+∞舍入–朝正无穷大方向舍入(也称为向上舍入或上限)。
  • Round toward −∞ – directed rounding towards negative infinity (also known as rounding down or floor). 向-∞取整-朝负无穷大方向定向(也称为向下取整或向下取整)。

Either there was a typesetting error, or you are not seeing it correctly. 可能是排版错误,或者您没有正确看到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM