Question
In C++ C: Output: "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"
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?
Solution
Try with printf("%f\n", fmodf(5.6f, 6.4f))
instead.
OTHER TIPS
Correcting the decimal problem with 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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow