Celeritas 0.6.0-dev.115+3b60a5fd
|
Full-precision floating point constant with automatic precision demotion. More...
#include <Constant.hh>
Public Types | |
Type aliases | |
using | real_type = double |
Public Member Functions | |
CELER_CONSTEXPR_FUNCTION | Constant (real_type v) |
Explicitly construct from a full-precision value. | |
CELER_CONSTEXPR_FUNCTION real_type | value () const |
Access the value explicitly. | |
CELER_CONSTEXPR_FUNCTION | operator float () const |
Explicit conversion of stored value. | |
CELER_CONSTEXPR_FUNCTION | operator double () const |
Explicit access to stored value. | |
Full-precision floating point constant with automatic precision demotion.
We want two behaviors from constants in Celeritas:
This class stores a full-precision (double) value as its "real type" and defines explicit conversion operators that allow it to automatically convert to a lower-precision or real-precision type.
Operations with a floating point value returns a value of that precision (performed at that precision level); operations with integers return a full-precision Constant; and operations with Constants return a Constant.