简体   繁体   English

等价于C#中的fmodf?

[英]Equivalent of fmodf in C#?

In C++ C: Output: "1610612736" C ++ C中:输出:“ 1610612736”

#include <math.h>
#include <stdio.h>

int main(int argc, char** argv)
{
    printf("%d\n", fmodf(5.6f, 6.4f));
    getchar();
}

In C#: Output: "5.6" 在C#中:输出:“ 5.6”

using System;

static class Program
{
    public static void Main(string[] args)
    {
        Console.WriteLine(5.6f % 6.4f);
        Console.Read();
    }
}

Clearly not the same output. 显然输出不一样。 Suggestions? 建议?

请尝试使用printf("%f\\n", fmodf(5.6f, 6.4f))

Correcting the decimal problem with fprintf() 用fprintf()纠正小数问题

#include <math.h>
#include <stdio.h>
#include <iostream>

int main(int argc, char** argv)
{
    std::cout << fmodf(5.6f, 6.4f) << std::endl;
    getchar();
}

Output 5.6 输出5.6

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

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