Basic Data Types


The MAXON API defines multiple primitive mathematical data types. These data types are the building blocks for more complex data types.

These data types should be used instead of the standard C++ data types.


maxon::Bool stores a Boolean value.

// This example stores and receives a Boolean value in a maxon::Data container.
const maxon::Bool boolean = data.Get<maxon::Bool>() iferr_return;
DiagnosticOutput("Boolean Value: @", boolean);
if (boolean)
DiagnosticOutput("Value is \"true\".");
Definition: datatypebase.h:1179
Result< void > Set(T &&data)
Definition: datatypebase.h:1373
Result< typename std::conditional< GetCollectionKind< T >::value==COLLECTION_KIND::ARRAY, T, typename ByValueParam< T >::type >::type > Get() const
Definition: datatypebase.h:1384
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:183
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
#define iferr_return
Definition: resultbase.h:1465


Different integer type of the sizes 16, 32 and 64 bit are defined:

// This example stores and receives an integer value in a maxon::Data container.
const maxon::Int64 integer = data.Get<maxon::Int64>() iferr_return;
DiagnosticOutput("Integer Value: @", integer);
int64_t Int64
64 bit signed integer datatype.
Definition: apibase.h:180

If such a integer value should be converted to a floating point value one must consider the limits of such conversion. Values outside that limit will result in an overflow.

For bigger integer values use maxon::BigInteger.


Floating point data types are available in 32 and 64 bit size:

A number can also be cast into a maxon::Float using the "_f" operator.
// This example stores and receives a float value in a maxon::Data container.
const maxon::Float32 floataValue = data.Get<maxon::Float32>() iferr_return;
DiagnosticOutput("Float Value: @", floataValue);
float Float32
32 bit floating point value (float)
Definition: apibase.h:184

Floating point data is a complex data type that could be corrupted.

Two floating point values (that are not exactly zero) should not be compared with "==".

// This example compares two floating point values.
const maxon::Float a = 0.35;
const maxon::Float b = 0.15;
const maxon::Float c = 0.5;
const maxon::Float sum = a + b;
// this may or may not work
if (sum == c)
DiagnosticOutput("Vales are the same.");
// this will work
DiagnosticOutput("Vales are the same.");
Float64 Float
Definition: apibase.h:199
Bool CompareFloatTolerant(Float32 a, Float32 b)

Different floating point data types have different minimum and maximum values:

Multiplying two float values could result in an overflow. These constants define safe ranges that can be used without the risk of such an overflow.

When a floating point value is converted into another scalar value it could easily exceed the range of valid values of the target type. A safe conversation is done with:

// This example converts a floating point result safely to a integer result.
const maxon::Int32 range = 1000;
const maxon::Float percentage = 0.15;
const maxon::Float res = percentage * maxon::Float(range);
const maxon::Int32 intRes = maxon::SafeConvert<maxon::Int32>(res);
int32_t Int32
32 bit signed integer datatype.
Definition: apibase.h:178


A character is a single symbol.

See also String Manual.


The Limit template class defines the minimum and maximum vale a given scalar type can store. An example is maxon::LIMIT<maxon::Int64>:

  • maxon::LIMIT<maxon::Int64>::MIN: The minimum value of the data type.
  • maxon::LIMIT<maxon::Int64>::MAX: The maximum value of the data type.
// This example function searches the minimum and maximum value stored in the given maxon::BaseArray.
// To compare a stored value the reference values are initialized with LIMIT<>::MIN and LIMIT<>::MAX.
if (!values)
return maxon::NullptrError(MAXON_SOURCE_LOCATION);
for (const maxon::Int& value :* values)
if (value < min)
min = value;
if (value > max)
max = value;
return maxon::OK;
Definition: basearray.h:413
Definition: apibasemath.h:54
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:190
return OK
Definition: apibase.h:2620
Definition: memoryallocationbase.h:67

Further Reading