[英]Equivalent of the php fmod in C#
Does anybody know what the C# equivalent of fmod is? 有人知道fmod的C#等效项是什么吗? I'm trying to convert this line of code to C#.
我正在尝试将这行代码转换为C#。
$lon_rad = fmod(($long1+$dlon_rad + M_PI), 2*M_PI) - M_PI;
Here's what I have so far. 到目前为止,这就是我所拥有的。 I just need the fmod converted.
我只需要转换fmod。
double lon_rad = ((lon1+dlon_rad + Math.PI), 2*Math.PI) - Math.PI;
其他人给了正确的运算符,但没有给出完整的语法,这是:
double lon_rad = ((lon1+dlon_rad + Math.PI) % (2*Math.PI)) - Math.PI;
您是否尝试过%模数运算符?
public static double fmod(double dividend, double divisor )
{
double Modulus =
(Math.Abs(dividend) - (Math.Abs(divisor) *
(Math.Floor(Math.Abs(dividend) / Math.Abs(divisor))))) *
Math.Sign(dividend);
return Modulus;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.