C++ (Qt) float f1 = QVector2D::dotProduct(v1,v2); // возвращает float double d1 = f1; double d2 = QVector2D::dotProduct(v1,v2); // повторяем
C++ (Qt)#include <QtCore>#include <QtGui> int main(int argc, char *argv[]){ QCoreApplication app(argc, argv); QTextStream ts(stdout, QIODevice::WriteOnly); QVector2D v1(8.10837e-09, -1); QVector2D v2(4.45843e-07, -1); float f1 = QVector2D::dotProduct(v1,v2); double d1 = f1; double d2 = QVector2D::dotProduct(v1,v2); ts.setRealNumberNotation(QTextStream::FixedNotation); ts.setRealNumberPrecision(20); ts << v1.x() << " " << v1.y() << " " << v2.x() << " " << v2.y() << " " << endl << f1 << " " << d1 << " " << d2 << endl; ts.flush(); return 0;}
C++ (Qt) float f1 = QVector2D::dotProduct(v1,v2); float f2 = QVector2D::dotProduct(v1,v2); double d1 = f1; double d2 = f2; double d3 = QVector2D::dotProduct(v1,v2); double d4 = QVector2D::dotProduct(v1,v2);
C++ (Qt)if (fabs(d1 - d2) < FUDGE_FACTOR) // считаем ==
C++ (Qt)QVector2D v1(8.10837e-09f, -1.0f);QVector2D v2(4.45843e-07f, -1.0f);
C++ (Qt)int main(int argc, char *argv[]){ QCoreApplication app(argc, argv); QTextStream ts(stdout, QIODevice::WriteOnly); QVector2D v1(8.10837e-09, -1); QVector2D v2(4.45843e-07, -1); // считаем руками const double d1 = v1.x() * v2.x() + v1.y() * v2.y(); // считаем стандартно const double d2 = QVector2D::dotProduct(v1,v2); ts.setRealNumberNotation(QTextStream::FixedNotation); ts.setRealNumberPrecision(20); ts << v1.x() << " " << v1.y() << " " << v2.x() << " " << v2.y() << " " << endl << d1 << " " << d2 << endl; ts.flush(); return 0;}
C++ (Qt) double d2 = 0.0f + QVector2D::dotProduct(v1, v2);
0.00000000810836997545 -1.00000000000000000000 0.00000044584299985218 -1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000