reactor-kotlin-extensions / reactor.kotlin.extra.math / reactor.core.publisher.Flux / sumDouble

sumDouble

fun <T : Number> Flux<T>.sumDouble(): Mono<Double>
Deprecated: Use sumAsDouble() instead

Extension to compute the Double sum of all values emitted by a Flux of Number and return it as a Mono of Double.

Note that since Double are more precise, some seemingly rounded Floats (e.g. 1.6f) may convert to Doubles with more decimals (eg. 1.600000023841858), producing sometimes unexpected sums.

Author
Simon Baslé

Since
1.0.0

Deprecated
Please use sumAsDouble() as a direct replacement, or consider more general purpose sumAll(). To be removed at the earliest in 1.3.0.

fun <T> Flux<T>.sumDouble(mapper: (T) -> Number): Mono<Double>
Deprecated: Use sumAll(mapper) instead

Extension to map arbitrary values in a Flux to Numbers and return the sum of these Numbers as a Mono of Double, thus avoiding rounding down to zero decimal places.

Note that since Double are more precise than Float, some seemingly rounded Floats (e.g. 1.6f) may convert to Doubles with more decimals (eg. 1.600000023841858), producing sometimes unexpected results.

Parameters

mapper - a lambda converting values to Number

Author
Simon Baslé

Since
1.0.0

Deprecated
Please use sumAll(mapper) as a direct replacement, providing a mapper function that returns a Double. To be removed at the earliest in 1.3.0.