mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
docs: update to define integer overflow
Change-Id: Ie8a1b31035f2d27a220e5df2e9e178ec3b39ee68
This commit is contained in:
parent
7b6622d733
commit
bf050d9e96
2 changed files with 13 additions and 2 deletions
|
@ -67,8 +67,12 @@ After evaluating *attrset* and *attrpath*, the computational complexity is O(log
|
||||||
|
|
||||||
## Arithmetic
|
## Arithmetic
|
||||||
|
|
||||||
Numbers are type-compatible:
|
Numbers will retain their type unless mixed with other numeric types:
|
||||||
Pure integer operations will always return integers, whereas any operation involving at least one floating point number return a floating point number.
|
Pure integer operations will always return integers, whereas any operation involving at least one floating point number returns a floating point number.
|
||||||
|
|
||||||
|
Evaluation of the following numeric operations throws an evaluation error:
|
||||||
|
- Division by zero
|
||||||
|
- Integer overflow, that is, any operation yielding a result outside of the representable range of [Nix language integers](./syntax.md#number-literal)
|
||||||
|
|
||||||
See also [Comparison] and [Equality].
|
See also [Comparison] and [Equality].
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,13 @@ This section covers syntax and semantics of the Nix language.
|
||||||
Numbers, which can be *integers* (like `123`) or *floating point*
|
Numbers, which can be *integers* (like `123`) or *floating point*
|
||||||
(like `123.43` or `.27e13`).
|
(like `123.43` or `.27e13`).
|
||||||
|
|
||||||
|
Integers in the Nix language are 64-bit [two's complement] signed integers, with a range of -9223372036854775808 to 9223372036854775807, inclusive.
|
||||||
|
|
||||||
|
[two's complement]: https://en.wikipedia.org/wiki/Two%27s_complement
|
||||||
|
|
||||||
|
Note that negative numeric literals are actually parsed as unary negation of positive numeric literals.
|
||||||
|
This means that the minimum integer `-9223372036854775808` cannot be written as-is as a literal, since the positive number `9223372036854775808` is one past the maximum range.
|
||||||
|
|
||||||
See [arithmetic] and [comparison] operators for semantics.
|
See [arithmetic] and [comparison] operators for semantics.
|
||||||
|
|
||||||
[arithmetic]: ./operators.md#arithmetic
|
[arithmetic]: ./operators.md#arithmetic
|
||||||
|
|
Loading…
Reference in a new issue