fuzzyCompare

Compares two floating point values and returns true if they are considered equal, false otherwise
301 téléchargements
Mise à jour 14 juin 2012

Afficher la licence

Compares two floating point values and returns true if they are considered equal, false otherwise. Inspired by Qt's qFuzzyCompare function. Two floating point variables that should in theory be equal, might not always be equal, due to mthe finite number of bits that a computational device uses to store and operate on values.

Ex:
num = 7;
sqrtd = sqrt(num);
sqrtd(2) = sqrt(sqrtd(1));
sqrtd(3) = sqrt(sqrtd(2))
prods(1) = sqrtd(end);
prods(2) = prods(1)^2;
prods(3) = prods(2)^2
finalNum = prods(3)^2
num==finalNum %This is false, though they should be the same
fuzzyCompare( num, finalNum ) %this is true

Citation pour cette source

Ivar Eskerud Smith (2024). fuzzyCompare (https://www.mathworks.com/matlabcentral/fileexchange/37160-fuzzycompare), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2012a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
1.0.0.0