WeBWorK Problems

When use cmp and when num_cmp?

Re: When use cmp and when num_cmp?

by Davide Cervone -
Number of replies: 0
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).

Hope that clears it up.

Davide