Convert var to double

I need to do something like this for a check function in a way that works for a1 being either double or var:

int num_terms;
num_terms = floor(fabs(a1));

Is there some standard function for this?


Of course I just needed to ask the question to figure it out, thanks, in reference to xkcd #979:


You should just be able to use value_of rather than value_of_rec, I think. The function floor returns a double, but you can cast it if you want to be explicit or just drop the cast. And you always want to declare-define where possible, so this should be:

int num_terms = static_cast<int>(floor(fabs(value_of(a1))));

assuming all those functions are in namespace.