fmod() unexpected sign
#1
fmod() unexpected sign
Hi there,

Im having a problem using fmod function (man fmod). On my O2 I get a signed result when it shouldnt be signed.

Could someone kindly try the following code and report back the result?

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

int main()
{
double a;

a = fmod(4.0L, 2.0L);

printf("a = %fL\n", a);

}

Compile with:

cc -o fmod fmod.c -lm

and

cc -o fmod fmod.c -lmx

My results are:

a = -0.000000 with both libraries.

The workaround I have found is to use drem() with -lm43 instead, which gives the expected result.

Strange.
TruHobbyist
Developer

Trade Count: (0)
Posts: 195
Threads: 21
Joined: May 2018
Find Reply
08-25-2019, 03:50 PM


Messages In This Thread
fmod() unexpected sign - by TruHobbyist - 08-25-2019, 03:50 PM
RE: fmod() unexpected sign - by dexter1 - 08-26-2019, 01:49 PM
RE: fmod() unexpected sign - by TruHobbyist - 08-26-2019, 04:31 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)