The gcc-bugs@gcc email list is for automated email from our bug
tracking database, not for reporting bugs, and not for "is this a
bug?" questions. I've CC'd this to the gcc-help list where this is
more appropriate (please remove gcc-bugs from any follow-up replies).
On 08/11/17 23:13 +0200, Nil Geisweiller wrote:
Hi,
The following
---------------------------------------------------------------------
#include <iostream>
#include <cmath>
int main()
{
double v = 4.6;
std::cout << "v = " << v << std::endl;
std::cout << "v*100 = " << v*100 << std::endl;
std::cout << "floor(v*100) = " << std::floor(v*100) << std::endl;
}
---------------------------------------------------------------------
outputs
------------------
v = 4.6
v*100 = 460
floor(v*100) = 459
------------------
It that a bug?
No.
Try:
#include <iostream>
#include <iomanip>
#include <cmath>
int main()
{
double v = 4.6;
std::cout << "v = " << std::setprecision(17) << v << std::endl;
std::cout << "v*100 = " << std::setprecision(16) << v*100 << std::endl;
std::cout << "floor(v*100) = " << std::floor(v*100) << std::endl;
}
If so where is the implementation of floor (so I can study and fix)? I
know it is supposed to be in gcc/builtins.c but I don't understand
where.
It doesn't necessarily use __builtin_floor anyway (without optimzation
it just calls the C library's floor(double) function).
You may run the program above from http://tpcg.io/QNfhYr
Thanks,
Nil