## WeBWorK Problems

### When use cmp and when num_cmp?

by Murray Eisenberg -
Number of replies: 1
I'm confused as to whether and when for checking the answer I can use cmp in the case of a numerical answer.
You use $ans->cmp When $ans is a MathObject (i.e., something created by Compute() or one of the specific constructors like Real(), Vector() or Formula()). You use num_cmp() when you are using a perl native real value rather than a MathObject.
The call num_cmp($p) is essentially equivalent to Real($p)->cmp (and indeed, num_cmp uses MathObjects behind the scenes).