gpt4 book ai didi

c - div() 库函数的用途是什么?

转载 作者:太空狗 更新时间:2023-10-29 15:43:50 24 4
gpt4 key购买 nike

当 C 有 / 运算符来划分两个数字时,div() library function 的目的是什么? ?

有没有/不能用而div()可以用的场景?

最佳答案

来自 C99 基本原理文档:

(7.20.6.2 The div, ldiv, and lldiv functions) Because C89 had implementation-defined semantics for division of signed integers when negative operands were involved, div and ldiv, and lldiv in C99, were invented to provide well-specified semantics for signed integer division and remainder operations. The semantics were adopted to be the same as in Fortran. Since these functions return both the quotient and the remainder, they also serve as a convenient way of efficiently modeling underlying hardware that computes both results as part of the same operation. [...] Now that C99 requires similar semantics for the division operator, the main reason for new programs to use div, ldiv or lldiv is to simultaneously obtain quotient and remainder.

关于c - div() 库函数的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11725884/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com