[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
g++ 4.9.2: Problematic output of fmod (long double, long double)
From: |
alex . vinokur |
Subject: |
g++ 4.9.2: Problematic output of fmod (long double, long double) |
Date: |
Thu, 11 Feb 2016 01:13:35 -0800 (PST) |
User-agent: |
G2/1.0 |
It seems that output of fmod (long double, long double) in this test is
problematocs.
Any suggestions?
See below.
> g++ --version
g++ (GCC) 4.9.2
> uname -srvmpio
CYGWIN_NT-6.1 1.7.34(0.285/5/3) 2015-02-04 12:12 i686 unknown unknown Cygwin
> g++ test1.cpp
// No errors, no warnings
> ./a.exe
l1 = 4294967296
l2 = 72057594037927934
l3 = 4294967294
d1 = 4294967296
d2 = 72057594037927934
d3 = 0 // Expected 4294967294
// -------- Program test1. cpp --------
#include <iostream>
#include <iomanip>
#include <cmath>
int main (int argc, char** argv)
{
long long l1 = 4294967296;
long long l2 = 72057594037927934;
long long l3 = l2 % l1;
long double d1 = static_cast<long double>(l1);
long double d2 = static_cast<long double>(l2);
long double d3 = fmod (d2, d1);
std::cout << "l1 = " << l1 << std::endl;
std::cout << "l2 = " << l2 << std::endl;
std::cout << "l3 = " << l3 << std::endl;
std::cout << std::endl;
std::cout << "d1 = " << std::setprecision(18) << d1 << std::endl;
std::cout << "d2 = " << std::setprecision(18) << d2 << std::endl;
std::cout << "d3 = " << std::setprecision(18) << d3 << std::endl;
return 0;
}
// -----------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- g++ 4.9.2: Problematic output of fmod (long double, long double),
alex . vinokur <=