Mark Storkamp said:

I've got a pdf file with some pseudo code that seems to have been

written by someone familiar with C++. I'm implementing the code in C,

but need help translating one particular line:

const int imax = 2*std::numeric_limits<Real>::max_exponent;

Can someone explain this and give me an equivalent C line of code? It

then iterates through a loop imax times.

You'd #include <float.h> and then use one of the three constants

FLT_MAX_EXP

DBL_MAX_EXP

LDBL_MAX_EXP

depending on what type 'Real' denotes (I'd guess it's a typedef):

const int imax = 2 * DBL_MAX_EXP;

I wonder what the 2 is there for. In case it matters, it's possible

that 2 * DBL_MAX_EXP != DBL_MAX_EXP - DBL_MIN_EXP.

[C++ explanation: std::numeric_limits is a class in the std namespace

(the namespace used by the standard library) which includes a bunch of

constants pertaining to numerical limits. It's what's call a templated

class, in that there is, in some sense, a version of it for any suitable

type written inside the <>s. So std::numeric_limits<float>::max_exponent

is a constant equivalent to C's FLT_MAX_EXP.]

If the C++ code is parameterised by the floating point type used, you

might have to use some combination of macros, the type generic maths

functions, and C11's new _Generic construct to get a faithful

translation. Why not to use C++?