roundN Helper

template<size_t MaxDeps = 8, typename Source>
auto RxESP32::Helpers::Numerical::roundN(Source &source, const uint8_t decimals = 0, const typename Computed<decltype(source.get()), 1, MaxDeps>::Options &options = {})

Round signal value to N decimal places.

Creates a Computed that rounds source values to the specified number of decimals.

Since

v0.1.0

Signal<float> value(3.14159);
auto rounded2 = roundN(value, 2);  // 3.14
auto rounded0 = roundN(value, 0);  // 3.0

Warning

Only accepts floating-point types (float, double).

Template Parameters:
size_t MaxDeps = 8

Maximum number of dependents for the computed signal.

Parameters:
Source &source

Source (determines result type).

const uint8_t decimals = 0

Number of decimal places (0 = round to integer).

const typename Computed<decltype(source.get()), 1, MaxDeps>::Options &options = {}

Optional Computed configuration.

Returns:

Computed with rounded values.

See Also