Skip to content

Commit

Permalink
feat: add options for behaviour when dividing by zero or calculating …
Browse files Browse the repository at this point in the history
…log zero (#329)

BREAKING CHANGE: options were added to division and logarithmic functions.
  • Loading branch information
thisisnic committed Sep 15, 2022
1 parent 4764192 commit 1c170c8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
12 changes: 11 additions & 1 deletion extensions/functions_arithmetic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ scalar_functions:
return: fp64
-
name: "divide"
description: "Divide one value by another. Partial values are truncated."
description: >
Divide x by y. In the case of integer division, partial values are truncated (i.e. rounded towards 0).
The `on_division_by_zero` option governs behavior in cases where y is 0 and x is not 0.
`LIMIT` means positive or negative infinity (depending on the sign of x and y).
If x and y are both 0 or both +/-infinity, behavior will be governed by `on_domain_error`.
impls:
- args:
- name: overflow
Expand Down Expand Up @@ -220,6 +224,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_division_by_zero
options: [ LIMIT, NAN, ERROR ]
required: false
- name: x
value: fp32
- name: y
Expand All @@ -232,6 +239,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_division_by_zero
options: [ LIMIT, NAN, ERROR ]
required: false
- name: x
value: fp64
- name: y
Expand Down
30 changes: 30 additions & 0 deletions extensions/functions_logarithmic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_log_zero
options: [NAN, ERROR, MINUS_INFINITY]
required: false
- name: x
value: fp32
return: fp32
Expand All @@ -22,6 +25,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_log_zero
options: [NAN, ERROR, MINUS_INFINITY]
required: false
- name: x
value: fp64
return: fp64
Expand All @@ -36,6 +42,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_log_zero
options: [NAN, ERROR, MINUS_INFINITY]
required: false
- name: x
value: fp32
return: fp32
Expand All @@ -46,6 +55,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_log_zero
options: [NAN, ERROR, MINUS_INFINITY]
required: false
- name: x
value: fp64
return: fp64
Expand All @@ -60,6 +72,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_log_zero
options: [NAN, ERROR, MINUS_INFINITY]
required: false
- name: x
value: fp32
return: fp32
Expand All @@ -70,6 +85,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_log_zero
options: [NAN, ERROR, MINUS_INFINITY]
required: false
- name: x
value: fp64
return: fp64
Expand All @@ -87,6 +105,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_log_zero
options: [NAN, ERROR, MINUS_INFINITY]
required: false
- value: fp32
name: "x"
description: "The number `x` to compute the logarithm of"
Expand All @@ -101,6 +122,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_log_zero
options: [NAN, ERROR, MINUS_INFINITY]
required: false
- value: fp64
name: "x"
description: "The number `x` to compute the logarithm of"
Expand All @@ -122,6 +146,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_log_zero
options: [NAN, ERROR, MINUS_INFINITY]
required: false
- name: x
value: fp32
return: fp32
Expand All @@ -132,6 +159,9 @@ scalar_functions:
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- name: on_log_zero
options: [NAN, ERROR, MINUS_INFINITY]
required: false
- name: x
value: fp64
return: fp64
Expand Down

0 comments on commit 1c170c8

Please sign in to comment.