https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61668
Bug ID: 61668
Summary: Division returns an error in some cases
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ketelbinkje at gmail dot com
Created attachment 33043
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33043&action=edit
A screen shot of the moment the error was detected
The issue:
The program wants to divide 59 by 100. The expected result is 0.59. The program
returns 0.58999999999999997. The next division r = dSeconds / (1000 * pow(10,
ceil(log10(x)))) returns the correct result.
Hardware:
HP 4600
Platform: Linux Mint 17 Cinnamon 64-bit
Cinamon version 2.2.13
Linux kernel 3.13.0-24-generic
Intel Xeon CPU 5140
Memory 7,8 GiB
Compiler and IDE:
g++ compiler version 4.8.2.
Code Blocks 13.12
The build log:
-------------- Clean: Debug in GCD (compiler: GNU GCC Compiler)---------------
Cleaned "GCD - Debug"
-------------- Build: Debug in GCD (compiler: GNU GCC Compiler)---------------
g++ -Wundef -Wunreachable-code -Weffc++ -std=c++11 -Wextra -Wall -g
-fexceptions -Wundef -Wunreachable-code -Wmissing-declarations -Wswitch-enum
-Wswitch-default -Weffc++ -std=c++11 -g -c
/home/fradiavolo/Projects/GCD/c_circlenavigation.cpp -o
obj/Debug/c_circlenavigation.o
In file included from /home/fradiavolo/Projects/GCD/c_circlenavigation.h:4:0,
from /home/fradiavolo/Projects/GCD/c_circlenavigation.cpp:1:
/home/fradiavolo/Projects/GCD/geotools.h:57:54: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double m_Degrees_2_Radians(const double);
^
/home/fradiavolo/Projects/GCD/geotools.h:58:54: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double m_Radians_2_Degrees(const double);
^
In file included from /home/fradiavolo/Projects/GCD/c_circlenavigation.h:4:0,
from /home/fradiavolo/Projects/GCD/c_circlenavigation.cpp:1:
/home/fradiavolo/Projects/GCD/geotools.h:61:165: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const bool m_Correct_GeoCoordinate(const string sCoordinate = "",
const CoordinateType::CoordinateProperty t =
CoordinateType::CoordinateProperty::Undefined);
^
/home/fradiavolo/Projects/GCD/geotools.h:64:169: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double m_ConvertCordinate_2_Double(const string sGeoCoordinate,
const CoordinateType::CoordinateProperty t =
CoordinateType::CoordinateProperty::Undefined);
^
/home/fradiavolo/Projects/GCD/geotools.h:67:34: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const bool m_ErrFlag(void) {return ErrFlag; };
^
g++ -Wundef -Wunreachable-code -Weffc++ -std=c++11 -Wextra -Wall -g
-fexceptions -Wundef -Wunreachable-code -Wmissing-declarations -Wswitch-enum
-Wswitch-default -Weffc++ -std=c++11 -g -c
/home/fradiavolo/Projects/GCD/geotools.cpp -o obj/Debug/geotools.o
In file included from /home/fradiavolo/Projects/GCD/geotools.cpp:1:0:
/home/fradiavolo/Projects/GCD/geotools.h:57:54: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double m_Degrees_2_Radians(const double);
^
/home/fradiavolo/Projects/GCD/geotools.h:58:54: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double m_Radians_2_Degrees(const double);
^
In file included from /home/fradiavolo/Projects/GCD/geotools.cpp:1:0:
/home/fradiavolo/Projects/GCD/geotools.h:61:165: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const bool m_Correct_GeoCoordinate(const string sCoordinate = "",
const CoordinateType::CoordinateProperty t =
CoordinateType::CoordinateProperty::Undefined);
^
/home/fradiavolo/Projects/GCD/geotools.h:64:169: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double m_ConvertCordinate_2_Double(const string sGeoCoordinate,
const CoordinateType::CoordinateProperty t =
CoordinateType::CoordinateProperty::Undefined);
^
/home/fradiavolo/Projects/GCD/geotools.h:67:34: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const bool m_ErrFlag(void) {return ErrFlag; };
^
/home/fradiavolo/Projects/GCD/geotools.cpp: In constructor
‘C_GeoTools::C_GeoTools()’:
/home/fradiavolo/Projects/GCD/geotools.cpp:11:1: warning: ‘C_GeoTools::ErrFlag’
should be initialized in the member initialization list [-Weffc++]
C_GeoTools::C_GeoTools()
^
/home/fradiavolo/Projects/GCD/geotools.cpp:11:1: warning: ‘C_GeoTools::ErrMsg’
should be initialized in the member initialization list [-Weffc++]
/home/fradiavolo/Projects/GCD/geotools.cpp: At global scope:
/home/fradiavolo/Projects/GCD/geotools.cpp:34:67: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double C_GeoTools::m_Degrees_2_Radians(const double dDegrees)
^
/home/fradiavolo/Projects/GCD/geotools.cpp:48:67: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double C_GeoTools::m_Radians_2_Degrees(const double dRadians)
^
/home/fradiavolo/Projects/GCD/geotools.cpp:60:116: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const bool C_GeoTools::m_Correct_GeoCoordinate(const string sCoordinate, const
CoordinateType::CoordinateProperty T)
^
/home/fradiavolo/Projects/GCD/geotools.cpp:121:125: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double C_GeoTools::m_ConvertCordinate_2_Double(const string
sGeoCoordinate, const CoordinateType::CoordinateProperty T)
^
/home/fradiavolo/Projects/GCD/geotools.cpp: In member function ‘const double
C_GeoTools::m_ConvertCordinate_2_Double(std::string,
C_GeoTools::CoordinateType::CoordinateProperty)’:
/home/fradiavolo/Projects/GCD/geotools.cpp:144:16: warning: variable ‘p’ set
but not used [-Wunused-but-set-variable]
double p = 0.0;
^
/home/fradiavolo/Projects/GCD/geotools.cpp:145:16: warning: variable ‘q’ set
but not used [-Wunused-but-set-variable]
double q = 0.0;
^
/home/fradiavolo/Projects/GCD/geotools.cpp:146:16: warning: variable ‘r’ set
but not used [-Wunused-but-set-variable]
double r = 0.0;
^
g++ -Wundef -Wunreachable-code -Weffc++ -std=c++11 -Wextra -Wall -g
-fexceptions -Wundef -Wunreachable-code -Wmissing-declarations -Wswitch-enum
-Wswitch-default -Weffc++ -std=c++11 -g -c
/home/fradiavolo/Projects/GCD/main.cpp -o obj/Debug/main.o
In file included from /home/fradiavolo/Projects/GCD/c_circlenavigation.h:4:0,
from /home/fradiavolo/Projects/GCD/main.cpp:1:
/home/fradiavolo/Projects/GCD/geotools.h:57:54: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double m_Degrees_2_Radians(const double);
^
/home/fradiavolo/Projects/GCD/geotools.h:58:54: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double m_Radians_2_Degrees(const double);
^
In file included from /home/fradiavolo/Projects/GCD/c_circlenavigation.h:4:0,
from /home/fradiavolo/Projects/GCD/main.cpp:1:
/home/fradiavolo/Projects/GCD/geotools.h:61:165: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const bool m_Correct_GeoCoordinate(const string sCoordinate = "",
const CoordinateType::CoordinateProperty t =
CoordinateType::CoordinateProperty::Undefined);
^
/home/fradiavolo/Projects/GCD/geotools.h:64:169: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const double m_ConvertCordinate_2_Double(const string sGeoCoordinate,
const CoordinateType::CoordinateProperty t =
CoordinateType::CoordinateProperty::Undefined);
^
/home/fradiavolo/Projects/GCD/geotools.h:67:34: warning: type qualifiers
ignored on function return type [-Wignored-qualifiers]
const bool m_ErrFlag(void) {return ErrFlag; };
^
g++ -o bin/Debug/GCD obj/Debug/c_circlenavigation.o obj/Debug/geotools.o
obj/Debug/main.o
Output file is bin/Debug/GCD with size 143,72 KB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 24 warning(s) (0 minute(s), 1 second(s))