diff --git a/content/flux/v0.x/data-types/basic/int.md b/content/flux/v0.x/data-types/basic/int.md index a7c9321e3..74f70c532 100644 --- a/content/flux/v0.x/data-types/basic/int.md +++ b/content/flux/v0.x/data-types/basic/int.md @@ -14,6 +14,7 @@ related: - /flux/v0.x/stdlib/universe/int/ - /flux/v0.x/stdlib/universe/toint/ - /flux/v0.x/stdlib/contrib/bonitoo-io/hex/int/ + - /flux/v0.x/stdlib/experimental/bitwise/ list_code_example: | ```js 0 @@ -178,6 +179,7 @@ data ## Operate on integers - [Perform arithmetic operations on integers](#perform-arithmetic-operations-on-integers) +- [Perform bitwise operations on integers](#perform-bitwise-operations-on-integers) - [Compare integers](#compare-integers) ### Perform arithmetic operations on integers @@ -207,6 +209,35 @@ When operating with integer operands, fractional results are truncated at the de // Returns 100 ``` +### Perform bitwise operations on integers +Use the [`experimental/bitwise` package](/flux/v0.x/stdlib/experimental/bitwise/) +to perform bitwise operations on integers. + +```js +import "experimental/bitwise" + +bitwise.sand(a: 12, b: 21) +// Returns 4 + +bitwise.sor(a: 12, b: 21) +// Returns 29 + +bitwise.sxor(a: 12, b: 21) +// Returns 25 + +bitwise.sclear(a: 12, b: 21) +// Returns 8 + +bitwise.snot(a: 12) +// Returns -13 + +bitwise.slshift(a: 12, b: 21) +// Returns 25165824 + +bitwise.srshift(a: 21, b: 4) +// Returns 1 +``` + ### Compare integers Use [Flux comparison operators](/flux/v0.x/spec/operators/#comparison-operators) to compare integers. diff --git a/content/flux/v0.x/data-types/basic/uint.md b/content/flux/v0.x/data-types/basic/uint.md index 9ba93e5db..55970c4e1 100644 --- a/content/flux/v0.x/data-types/basic/uint.md +++ b/content/flux/v0.x/data-types/basic/uint.md @@ -14,6 +14,7 @@ related: - /flux/v0.x/stdlib/universe/uint/ - /flux/v0.x/stdlib/universe/touint/ - /flux/v0.x/stdlib/contrib/bonitoo-io/hex/uint/ + - /flux/v0.x/stdlib/experimental/bitwise/ list_code_example: | ```js uint(v: 123) @@ -176,6 +177,7 @@ data ## Operate on uintegers - [Perform arithmetic operations on uintegers](#perform-arithmetic-operations-on-uintegers) +- [Perform bitwise operations on uintegers](#perform-bitwise-operations-on-uintegers) - [Compare uintegers](#compare-uintegers) ### Perform arithmetic operations on uintegers @@ -205,6 +207,35 @@ uint(v: 10) ^ uint(v: 2) // Returns 100 ``` +### Perform bitwise operations on uintegers +Use the [`experimental/bitwise` package](/flux/v0.x/stdlib/experimental/bitwise/) +to perform bitwise operations on uintegers. + +```js +import "experimental/bitwise" + +bitwise.uand(a: uint(v: 12), b: uint(v: 21)) +// Returns 4 + +bitwise.uor(a: uint(v: 12), b: uint(v: 21)) +// Returns 29 + +bitwise.uxor(a: uint(v: 12), b: uint(v: 21)) +// Returns 25 + +bitwise.uclear(a: uint(v: 12), b: uint(v: 21)) +// Returns 8 + +bitwise.unot(a: uint(v: 12)) +// Returns 18446744073709551603 + +bitwise.ulshift(a: uint(v: 12), b: uint(v: 21)) +// Returns 25165824 + +bitwise.urshift(a: uint(v: 21), b: uint(v: 4)) +// Returns 1 +``` + ### Compare uintegers Use [Flux comparison operators](/flux/v0.x/spec/operators/#comparison-operators) to compare uintegers. diff --git a/content/flux/v0.x/release-notes.md b/content/flux/v0.x/release-notes.md index 873e5f643..17ef4f0ef 100644 --- a/content/flux/v0.x/release-notes.md +++ b/content/flux/v0.x/release-notes.md @@ -10,6 +10,30 @@ aliases: - /influxdb/cloud/reference/release-notes/flux/ --- +## v0.139.0 [2021-11-01] + +### Features +- Continue type inference through errors at runtime. + +### Bug fixes +- Revert `runtime.now()` and related updates. + +--- + +## v0.138.0 [2021-11-01] + +### Features +- Create a BigTable dependency to let Flux mimic or control BigTable API usage. +- Report multiple type inference errors. +- Add [bitwise operations](/flux/v0.x/stdlib/experimental/bitwise/). + +### Bug fixes +- Update [`fill()`](/flux/v0.x/stdlib/universe/fill/) to return tables unchanged + when using `usePrevious` to fill a non-existent column. +- Add `runtime.now()` to return the same time throughout a script execution. + +--- + ## v0.137.0 [2021-10-28] ### Features diff --git a/content/flux/v0.x/spec/types.md b/content/flux/v0.x/spec/types.md index a17c47ffa..f1e2efad7 100644 --- a/content/flux/v0.x/spec/types.md +++ b/content/flux/v0.x/spec/types.md @@ -108,6 +108,10 @@ Durations can be added to times to produce a new time. 3d12h4m25s // 3 days, 12 hours, 4 minutes, and 25 seconds ``` +{{% note %}} +[IMPL#2026](https://github.com/influxdata/flux/issues/2026) Operator for time arithmetic +{{% /note %}} + ### String types A _string type_ represents a possibly empty sequence of characters. Strings are immutable and cannot be modified once created. diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/_index.md b/content/flux/v0.x/stdlib/experimental/bitwise/_index.md new file mode 100644 index 000000000..d2916ab6a --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/_index.md @@ -0,0 +1,30 @@ +--- +title: Flux experimental bitwise package +list_title: bitwise package +description: > + The Flux experimental `bitwise` package provides functions for performing + bitwise operations on integers. + Import the `experimental/bitwise` package. +menu: + flux_0_x_ref: + name: bitwise + parent: experimental +weight: 301 +flux/v0.x/tags: [functions, bitwise, package] +cascade: + introduced: 0.138.0 +--- + +The Flux experimental `bitwise` package provides functions for performing bitwise +operations on integers and unsigned integers. +Import the `experimental/bitwise` package: + +```js +import "experimental/bitwise" +``` + +## Functions +Functions prefixed with `s` operate on [signed integers (int)](/flux/v0.x/data-types/basic/int/#perform-bitwise-operations-on-integers). +Functions prefixed with `u` operate on [unsigned integers (uint)](/flux/v0.x/data-types/basic/uint/#perform-bitwise-operations-on-uintegers). + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/sand.md b/content/flux/v0.x/stdlib/experimental/bitwise/sand.md new file mode 100644 index 000000000..81050692d --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/sand.md @@ -0,0 +1,36 @@ +--- +title: bitwise.sand() function +description: > + `bitwise.sand()` performs the bitwise operation `a AND b` with + [integer](/flux/v0.x/data-types/basic/int/) values. +menu: + flux_0_x_ref: + name: bitwise.sand + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/int/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.sand()` performs the bitwise operation, `a AND b`, with +[integer](/flux/v0.x/data-types/basic/int/) values. + +```js +import "experimental/bitwise" + +bitwise.sand( + a: 12, + b: 21 +) + +// Returns 4 +``` + +## Parameters + +### a {data-type="int"} +Left operand. + +### b {data-type="int"} +Right operand. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/sclear.md b/content/flux/v0.x/stdlib/experimental/bitwise/sclear.md new file mode 100644 index 000000000..e562f9eda --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/sclear.md @@ -0,0 +1,36 @@ +--- +title: bitwise.sclear() function +description: > + `bitwise.sclear()` performs the bitwise operation `a AND NOT b` with + [integer](/flux/v0.x/data-types/basic/int/) values. +menu: + flux_0_x_ref: + name: bitwise.sclear + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/int/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.sclear()` performs the bitwise operation, `a AND NOT b`, with +[integer](/flux/v0.x/data-types/basic/int/) values. + +```js +import "experimental/bitwise" + +bitwise.sclear( + a: 12, + b: 21 +) + +// Returns 8 +``` + +## Parameters + +### a {data-type="int"} +Left operand. + +### b {data-type="int"} +Right operand. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/slshift.md b/content/flux/v0.x/stdlib/experimental/bitwise/slshift.md new file mode 100644 index 000000000..95369a9e8 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/slshift.md @@ -0,0 +1,36 @@ +--- +title: bitwise.slshift() function +description: > + `bitwise.slshift()` shifts bits in `a` left by `b` bits. + Both `a` and `b` are [integers](/flux/v0.x/data-types/basic/int/). +menu: + flux_0_x_ref: + name: bitwise.slshift + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/int/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.slshift()` shifts bits in `a` left by `b` bits. +Both `a` and `b` are [integers](/flux/v0.x/data-types/basic/int/). + +```js +import "experimental/bitwise" + +bitwise.slshift( + a: 12, + b: 21 +) + +// Returns 25165824 +``` + +## Parameters + +### a {data-type="int"} +Left operand. + +### b {data-type="int"} +Number of bits to shift. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/snot.md b/content/flux/v0.x/stdlib/experimental/bitwise/snot.md new file mode 100644 index 000000000..2e72a6494 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/snot.md @@ -0,0 +1,30 @@ +--- +title: bitwise.snot() function +description: > + `bitwise.snot()` inverts every bit in `a`, an + [integer](/flux/v0.x/data-types/basic/int/) value. +menu: + flux_0_x_ref: + name: bitwise.snot + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/int/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.snot()` inverts every bit in `a`, an +[integer](/flux/v0.x/data-types/basic/int/) value. + +```js +import "experimental/bitwise" + +bitwise.snot(a: 12) + +// Returns -13 +``` + +## Parameters + +### a {data-type="int"} +Integer to invert. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/sor.md b/content/flux/v0.x/stdlib/experimental/bitwise/sor.md new file mode 100644 index 000000000..2c95b3b81 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/sor.md @@ -0,0 +1,36 @@ +--- +title: bitwise.sor() function +description: > + `bitwise.sor()` performs the bitwise operation `a OR b` with + [integer](/flux/v0.x/data-types/basic/int/) values. +menu: + flux_0_x_ref: + name: bitwise.sor + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/int/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.sor()` performs the bitwise operation, `a OR b`, with +[integer](/flux/v0.x/data-types/basic/int/) values. + +```js +import "experimental/bitwise" + +bitwise.sor( + a: 12, + b: 21 +) + +// Returns 29 +``` + +## Parameters + +### a {data-type="int"} +Left operand. + +### b {data-type="int"} +Right operand. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/srshift.md b/content/flux/v0.x/stdlib/experimental/bitwise/srshift.md new file mode 100644 index 000000000..3b3eec84b --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/srshift.md @@ -0,0 +1,36 @@ +--- +title: bitwise.srshift() function +description: > + `bitwise.srshift()` shifts bits in `a` right by `b` bits. + Both `a` and `b` are [integers](/flux/v0.x/data-types/basic/int/). +menu: + flux_0_x_ref: + name: bitwise.srshift + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/int/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.srshift()` shifts bits in `a` right by `b` bits. +Both `a` and `b` are [integers](/flux/v0.x/data-types/basic/int/). + +```js +import "experimental/bitwise" + +bitwise.srshift( + a: 21, + b: 4 +) + +// Returns 1 +``` + +## Parameters + +### a {data-type="int"} +Left operand. + +### b {data-type="int"} +Number of bits to shift. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/sxor.md b/content/flux/v0.x/stdlib/experimental/bitwise/sxor.md new file mode 100644 index 000000000..58348918a --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/sxor.md @@ -0,0 +1,36 @@ +--- +title: bitwise.sxor() function +description: > + `bitwise.sxor()` performs the bitwise operation `a XOR b` with + [integer](/flux/v0.x/data-types/basic/int/) values. +menu: + flux_0_x_ref: + name: bitwise.sxor + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/int/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.sxor()` performs the bitwise operation, `a XOR b`, with +[integer](/flux/v0.x/data-types/basic/int/) values. + +```js +import "experimental/bitwise" + +bitwise.sxor( + a: 12, + b: 21 +) + +// Returns 25 +``` + +## Parameters + +### a {data-type="int"} +Left operand. + +### b {data-type="int"} +Right operand. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/uand.md b/content/flux/v0.x/stdlib/experimental/bitwise/uand.md new file mode 100644 index 000000000..9490f90e1 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/uand.md @@ -0,0 +1,36 @@ +--- +title: bitwise.uand() function +description: > + `bitwise.uand()` performs the bitwise operation `a AND b` with + [unsigned integer](/flux/v0.x/data-types/basic/uint/) values. +menu: + flux_0_x_ref: + name: bitwise.uand + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/uint/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.uand()` performs the bitwise operation, `a AND b`, with +[unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + +```js +import "experimental/bitwise" + +bitwise.uand( + a: uint(v: 12), + b: uint(v: 21) +) + +// Returns 4 (uint) +``` + +## Parameters + +### a {data-type="uint"} +Left operand. + +### b {data-type="uint"} +Right operand. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/uclear.md b/content/flux/v0.x/stdlib/experimental/bitwise/uclear.md new file mode 100644 index 000000000..7a84a917f --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/uclear.md @@ -0,0 +1,36 @@ +--- +title: bitwise.uclear() function +description: > + `bitwise.uclear()` performs the bitwise operation `a AND NOT b` with + [unsigned integer](/flux/v0.x/data-types/basic/uint/) values. +menu: + flux_0_x_ref: + name: bitwise.uclear + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/uint/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.uclear()` performs the bitwise operation, `a AND NOT b`, with +[unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + +```js +import "experimental/bitwise" + +bitwise.uclear( + a: uint(v: 12), + b: uint(v: 21) +) + +// Returns 8 (uint) +``` + +## Parameters + +### a {data-type="uint"} +Left operand. + +### b {data-type="uint"} +Right operand. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/ulshift.md b/content/flux/v0.x/stdlib/experimental/bitwise/ulshift.md new file mode 100644 index 000000000..0d447d2c9 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/ulshift.md @@ -0,0 +1,36 @@ +--- +title: bitwise.ulshift() function +description: > + `bitwise.ulshift()` shifts bits in `a` left by `b` bits. + Both `a` and `b` are [unsigned integers](/flux/v0.x/data-types/basic/uint/). +menu: + flux_0_x_ref: + name: bitwise.ulshift + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/uint/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.ulshift()` shifts bits in `a` left by `b` bits. +Both `a` and `b` are [unsigned integers](/flux/v0.x/data-types/basic/uint/). + +```js +import "experimental/bitwise" + +bitwise.ulshift( + a: uint(v: 12), + b: uint(v: 21) +) + +// Returns 25165824 (uint) +``` + +## Parameters + +### a {data-type="uint"} +Left operand. + +### b {data-type="uint"} +Number of bits to shift. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/unot.md b/content/flux/v0.x/stdlib/experimental/bitwise/unot.md new file mode 100644 index 000000000..7726b0dc4 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/unot.md @@ -0,0 +1,30 @@ +--- +title: bitwise.unot() function +description: > + `bitwise.unot()` inverts every bit in `a`, an + [unsigned integer](/flux/v0.x/data-types/basic/uint/) value. +menu: + flux_0_x_ref: + name: bitwise.unot + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/uint/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.unot()` inverts every bit in `a`, an +[unsigned integer](/flux/v0.x/data-types/basic/uint/) value. + +```js +import "experimental/bitwise" + +bitwise.unot(a: uint(v: 12)) + +// Returns 18446744073709551603 (uint) +``` + +## Parameters + +### a {data-type="uint"} +Unsigned integer to invert. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/uor.md b/content/flux/v0.x/stdlib/experimental/bitwise/uor.md new file mode 100644 index 000000000..a2347a303 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/uor.md @@ -0,0 +1,36 @@ +--- +title: bitwise.uor() function +description: > + `bitwise.uor()` performs the bitwise operation `a OR b` with + [unsigned integer](/flux/v0.x/data-types/basic/uint/) values. +menu: + flux_0_x_ref: + name: bitwise.uor + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/uint/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.uor()` performs the bitwise operation, `a OR b`, with +[unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + +```js +import "experimental/bitwise" + +bitwise.uor( + a: uint(v: 12), + b: uint(v: 21) +) + +// Returns 29 (uint) +``` + +## Parameters + +### a {data-type="uint"} +Left operand. + +### b {data-type="uint"} +Right operand. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/urshift.md b/content/flux/v0.x/stdlib/experimental/bitwise/urshift.md new file mode 100644 index 000000000..b751a6cc6 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/urshift.md @@ -0,0 +1,36 @@ +--- +title: bitwise.urshift() function +description: > + `bitwise.urshift()` shifts bits in `a` right by `b` bits. + Both `a` and `b` are [unsigned integers](/flux/v0.x/data-types/basic/uint/). +menu: + flux_0_x_ref: + name: bitwise.urshift + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/uint/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.urshift()` shifts bits in `a` right by `b` bits. +Both `a` and `b` are [unsigned integers](/flux/v0.x/data-types/basic/uint/). + +```js +import "experimental/bitwise" + +bitwise.urshift( + a: uint(v: 21), + b: uint(v: 4) +) + +// Returns 1 (uint) +``` + +## Parameters + +### a {data-type="uint"} +Left operand. + +### b {data-type="uint"} +Number of bits to shift. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/experimental/bitwise/uxor.md b/content/flux/v0.x/stdlib/experimental/bitwise/uxor.md new file mode 100644 index 000000000..7ded84782 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/bitwise/uxor.md @@ -0,0 +1,36 @@ +--- +title: bitwise.uxor() function +description: > + `bitwise.uxor()` performs the bitwise operation `a XOR b` with + [unsigned integer](/flux/v0.x/data-types/basic/uint/) values. +menu: + flux_0_x_ref: + name: bitwise.uxor + parent: bitwise +weight: 401 +related: + - /flux/v0.x/data-types/basic/uint/ +flux/v0.x/tags: [bitwise] +--- + +`bitwise.uxor()` performs the bitwise operation, `a XOR b`, with +[unsigned integer](/flux/v0.x/data-types/basic/uint/) values. + +```js +import "experimental/bitwise" + +bitwise.uxor( + a: uint(v: 12), + b: uint(v: 21) +) + +// Returns 25 (uint) +``` + +## Parameters + +### a {data-type="uint"} +Left operand. + +### b {data-type="uint"} +Right operand. \ No newline at end of file diff --git a/content/flux/v0.x/stdlib/universe/_index.md b/content/flux/v0.x/stdlib/universe/_index.md index fc8362db7..3f6e6105d 100644 --- a/content/flux/v0.x/stdlib/universe/_index.md +++ b/content/flux/v0.x/stdlib/universe/_index.md @@ -24,7 +24,7 @@ The "built-in" functions in the `universe` package provide a foundation for work The `universe` package provides the following options: ```js -option now = () => system.time +option now = () => system.time() option location = timezone.utc ```