Skip to content

Commit 833f184

Browse files
doc: document implementation-specific limits on numeric domain of bitwise operations
1 parent 1f5ec05 commit 833f184

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

doc/ref/language.html.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ Jsonnet numbers are 64-bit floating point numbers as defined in IEEE754 excludin
135135

136136
Integers can be safely represented as a Jsonnet number in the range [-2^53 + 1,2^53 - 1]. This is [a direct consequence of IEEE754 spec](https://en.wikipedia.org/wiki/Double-precision_floating-point_format), with the requirements that a safe integer is representable exactly, and cannot be produced by rounding any other integer to fit the IEEE-754 representation. See also, the JavaScript [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER), [`Number.MIN_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER), and [`Number.isSafeInteger`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger) definitions.
137137

138+
Currently, the C++ and Go Jsonnet implementations restrict the arguments (inputs) to binary bitwise operations (the operators `<<`, `>>`, `&`, `|`, and `^`) to the safe integer range.
139+
138140
### Function
139141

140142
Functions in Jsonnet are functions in the mathematical sense. Each function has parameters and a body expression. The result of calling a function is equivalent to the result of evaluating its body with arguments introduced to the environment.

doc/ref/spec.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,8 @@ <h4 id="execution">Execution</h4>
28262826
standard way, then convert back to IEEE double precision floating point. In shift
28272827
operations <code>&lt;&lt;</code>, <code>&gt;&gt;</code>, the right hand value modulo 64 is
28282828
interpreted as the shift count. Shifting with a negative shift count raises an error.
2829+
Individiual Jsonnet implementations may place further restrictions on the range of inputs
2830+
or outputs to bitwise operations.
28292831
</li>
28302832
<li>
28312833
<b>Standard functions</b>: The following functions have standard mathematical behavior

0 commit comments

Comments
 (0)