Skip to main content
Version: 1.4.0

Floor

Math Data Analysis

Synopsis

Calculates the floor function of numeric values, returning the largest integer that is less than or equal to the input value.

Schema

- floor:
description: <text>
field: <ident>
value: <string>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

The following fields are used to define the processor:

FieldRequiredDefaultDescription
fieldYField to store the floor result
valueYNumeric value or field reference to calculate floor for
descriptionN-Explanatory notes
ifN-Condition to run
ignore_failureNfalseSee Handling Failures
ignore_missingNfalseContinue processing if referenced fields are missing
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier

Details

The processor applies the mathematical floor function to numeric values. The floor function returns the largest integer that is less than or equal to the input value. For example:

  • floor(3.7) = 3
  • floor(-2.3) = -3
  • floor(5.0) = 5
  • floor(-1.0) = -1

The value parameter can be either a literal numeric value or a field reference. When using field references, the processor will resolve the field value and apply the floor operation to it.

info

The floor function is commonly used in data processing for grouping continuous values into discrete buckets, time-based calculations, and normalization operations.

note

For negative numbers, the floor function rounds towards negative infinity, not towards zero. This means floor(-2.3) equals -3, not -2.

tip

Use the floor processor in combination with mathematical operations to create time-based groupings, such as rounding timestamps to the nearest hour or creating histogram buckets.

Examples

Basic Floor Operation

Calculate the floor of a decimal value...

{
"price": 19.99
}
- floor:
field: price_floor
value: "{{price}}"

to get the integer part:

{
"price": 19.99,
"price_floor": 19
}

Negative Number Floor

Floor of negative numbers...

{
"temperature": -2.7
}
- floor:
field: temp_floor
value: "{{temperature}}"

rounds towards negative infinity:

{
"temperature": -2.7,
"temp_floor": -3
}

Time Bucket Creation

Create hourly time buckets...

{
"timestamp": 1705318847.234,
"hour_seconds": 3600
}
- floor:
field: hour_bucket
value: "{{timestamp}} / {{hour_seconds}}"

for time-based grouping:

{
"timestamp": 1705318847.234,
"hour_seconds": 3600,
"hour_bucket": 473699
}

Literal Values

Use literal numeric values...

{
"data": "processing"
}
- floor:
field: constant_floor
value: "7.89"

for constant calculations:

{
"data": "processing",
"constant_floor": 7
}

Score Normalization

Normalize scores to integer ranges...

{
"raw_score": 87.6,
"max_score": 100,
"scale_factor": 10
}
- floor:
field: normalized_score
value: "{{raw_score}} / {{max_score}} * {{scale_factor}}"

for categorical grouping:

{
"raw_score": 87.6,
"max_score": 100,
"scale_factor": 10,
"normalized_score": 8
}

Percentage Buckets

Create percentage buckets...

{
"completion_rate": 0.847
}
- floor:
field: completion_bucket
value: "{{completion_rate}} * 10"

for progress tracking:

{
"completion_rate": 0.847,
"completion_bucket": 8
}

In-Place Modification

Modify the original field...

{
"average_rating": 4.73
}
- floor:
field: average_rating
value: "{{average_rating}}"

by using the same field name:

{
"average_rating": 4
}

Complex Expressions

Use complex mathematical expressions...

{
"value_a": 15.7,
"value_b": 8.2,
"multiplier": 2.5
}
- floor:
field: complex_result
value: "({{value_a}} + {{value_b}}) * {{multiplier}} / 10"

for advanced calculations:

{
"value_a": 15.7,
"value_b": 8.2,
"multiplier": 2.5,
"complex_result": 5
}

Zero and Integer Values

Floor of integers and zero...

{
"integer_val": 42,
"zero_val": 0
}
- floor:
field: int_floor
value: "{{integer_val}}"
- floor:
field: zero_floor
value: "{{zero_val}}"

remain unchanged:

{
"integer_val": 42,
"zero_val": 0,
"int_floor": 42,
"zero_floor": 0
}