Bug in std::floor?

Nil Geisweiller ngeiswei@googlemail.com
Wed Nov 8 21:13:00 GMT 2017


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?

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.

You may run the program above from http://tpcg.io/QNfhYr

Thanks,

Nil



More information about the Gcc-bugs mailing list