Logo Search packages:      
Sourcecode: quantlib version File versions  Download package

bool close_enough ( const Quantity ,
const Quantity ,
Size  n = 42 
) [related]

Definition at line 182 of file quantity.cpp.

References amount(), AutomatedConversion, BaseUnitOfMeasureConversion, QL_FAIL, and unitOfMeasure().

                                                                      {
        if (m1.unitOfMeasure() == m2.unitOfMeasure()) {
            return close_enough(m1.amount(),m2.amount(),n);
        } else if (Quantity::conversionType
                   == Quantity::BaseUnitOfMeasureConversion) {
            Quantity tmp1 = m1;
            convertToBase(tmp1);
            Quantity tmp2 = m2;
            convertToBase(tmp2);
            return close_enough(tmp1,tmp2,n);
        } else if (Quantity::conversionType == Quantity::AutomatedConversion) {
            Quantity tmp = m2;
            convertTo(tmp, m1.unitOfMeasure());
            return close_enough(m1,tmp,n);
        } else {
            QL_FAIL("unitOfMeasure mismatch and no conversion specified");
        }
    }


Generated by  Doxygen 1.6.0   Back to index