chapel

Max value for numeric data types in Chapel


I am in need of the maximum value for a real(64), but I do not see a way to directly access this value from any of the standard modules.

For now, my Chapel code is below, but I was hoping there would be a function or macro which would return the max value of a real(64).

const float_max: real(64) = 1.7976931348623157E308;

In C for example, this is achieved using the DBL_MAX macro defined in float.h:

#include <float.h>

const double double_max = DBL_MAX;

Is there a module I have overlooked which will help me out, or do I need to hardcode the maximum value?


Solution

  • I think what you're looking for is in the Types module: https://chapel-lang.org/docs/modules/standard/Types.html#Types.max

    Note that the Types module is provided by default, so no use or import statement should be necessary to access it.