For given floating point numbers x
and a
, I would like to compute r
(and n
) such that x = a*n + r
. In C/C++ this function is called fmod
. However I do not see a convenient function in .NET. Math.DivRem is only for integers ...
I think you can just use %
for floats as well. r = x % a
" Arithmetic operators (C# reference) ":
All numeric types have predefined modulus operators.
我想你正在寻找System.Math.IeeeRemainder
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.