c++ - Checking if two vectors are equal -


i have 2 vectors:

std::vector<double> calculatedvalues = calculatevalues(); std::vector<double> expectedvalues = {1.1, 1.2}; 

i using cpputest verify if these vectors equal:

check_true(calculatedvalues == expectedvalues) 

this working. however, wondering whether shouldn't use tolerance, because after comparing doubles.

to compare floating point values should this:

bool is_equal(double a, double b) {      return (abs(a-b)/b < 0.0001); // 0.00001 value can relative value } 

you can adapt compare vectors.


Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -