Skip to content

fsub

Input Stack:
ts2: TimeSeriesExpr
ts1: TimeSeriesExpr
Output Stack:
(ts1 - ts2): TimeSeriesExpr
 

Floating point subtraction operator that follows strict IEEE 754 floating point arithmetic. Compute a new time series where each interval has the value (ts1 - ts2) where values are the corresponding intervals in the input time series.

Parameters

  • ts1: First time series expression (left operand, minuend)
  • ts2: Second time series expression (right operand, subtrahend)

NaN Handling

Unlike :sub, this operator follows standard floating point rules where any operation involving NaN produces NaN as the result:

:fsub 1.0 0.0 1.0 NaN NaN
Input 1 2.0 0.0 1.0 1.0 NaN
Input 2 1.0 0.0 0.0 NaN NaN

Warning

This can lead to confusing behavior when combining time series with missing data. If a time series has NaN values (e.g., from a node that started reporting mid-window), the result will be NaN. Use :sub instead to treat NaN values as zero.

Examples

Subtracting a constant value:

BeforeAfter
name,sps,:eq
name,sps,:eq,
30000,:fsub

Subtracting two time series:

BeforeAfter
name,requestLatency,:eq,
:sum,
name,requestsPerSecond,:eq,
:max,
(,name,),:by
name,requestLatency,:eq,
:sum,
name,requestsPerSecond,:eq,
:max,
(,name,),:by,
:fsub
  • :sub - Subtraction with NaN treated as 0 (often preferred for time series)
  • :fadd - Floating point addition
  • :fmul - Floating point multiplication
  • :fdiv - Floating point division