From b8f9d9d4ee8afa5852c162fea9b0b4ddd02017dc Mon Sep 17 00:00:00 2001 From: Savio <72797635+Savio-Sou@users.noreply.github.com> Date: Sat, 21 Oct 2023 03:39:18 +0800 Subject: [PATCH 1/4] Remove mentioning of Field as default integer --- docs/docs/language_concepts/data_types/00_fields.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/language_concepts/data_types/00_fields.md b/docs/docs/language_concepts/data_types/00_fields.md index 658a0441ffb..f8d01a7709b 100644 --- a/docs/docs/language_concepts/data_types/00_fields.md +++ b/docs/docs/language_concepts/data_types/00_fields.md @@ -18,7 +18,7 @@ The size of a Noir field depends on the elliptic curve's finite field for the pr adopted. For example, a field would be a 254-bit integer when paired with the default backend that spans the Grumpkin curve. -Fields support integer arithmetic and are often used as the default numeric type in Noir: +Fields support integer arithmetic: ```rust fn main(x : Field, y : Field) { From eacae6ad0e5f4c99709a5eda7e21e8ef11ce05c9 Mon Sep 17 00:00:00 2001 From: Savio <72797635+Savio-Sou@users.noreply.github.com> Date: Sat, 21 Oct 2023 03:46:59 +0800 Subject: [PATCH 2/4] Mention `u64` is the default integer type --- .../docs/language_concepts/data_types/01_integers.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/docs/language_concepts/data_types/01_integers.md b/docs/docs/language_concepts/data_types/01_integers.md index d9c5e20e795..37f9ec7a7da 100644 --- a/docs/docs/language_concepts/data_types/01_integers.md +++ b/docs/docs/language_concepts/data_types/01_integers.md @@ -15,9 +15,16 @@ keywords: An integer type is a range constrained field type. The Noir frontend currently supports unsigned, arbitrary-sized integer types. +> **Note:** When an integer is defined in Noir without a specific type, it would default to `u64`. + An integer type is specified first with the letter `u`, indicating its unsigned nature, followed by its length in bits (e.g. `32`). For example, a `u32` variable can store a value in the range of -$\\([0,2^{32}-1]\\)$: +$\\([0,2^{32}-1]\\)$. + +> **Note:** The default proving backend supports both even (e.g. `u16`, `u48`) and odd (e.g. `u5`, `u3`) +> sized integer types. + +Taking a look of how the type is used: ```rust fn main(x : Field, y : u32) { @@ -28,6 +35,3 @@ fn main(x : Field, y : u32) { `x`, `y` and `z` are all private values in this example. However, `x` is a field while `y` and `z` are unsigned 32-bit integers. If `y` or `z` exceeds the range $\\([0,2^{32}-1]\\)$, proofs created will be rejected by the verifier. - -> **Note:** The default backend supports both even (e.g. `u16`, `u48`) and odd (e.g. `u5`, `u3`) -> sized integer types. From 865ca21e13d3136dad33dbcaa400cb76b9298740 Mon Sep 17 00:00:00 2001 From: Savio <72797635+Savio-Sou@users.noreply.github.com> Date: Thu, 26 Oct 2023 01:05:30 +0800 Subject: [PATCH 3/4] Update docs/docs/language_concepts/data_types/00_fields.md Co-authored-by: jfecher --- docs/docs/language_concepts/data_types/00_fields.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/language_concepts/data_types/00_fields.md b/docs/docs/language_concepts/data_types/00_fields.md index f8d01a7709b..658a0441ffb 100644 --- a/docs/docs/language_concepts/data_types/00_fields.md +++ b/docs/docs/language_concepts/data_types/00_fields.md @@ -18,7 +18,7 @@ The size of a Noir field depends on the elliptic curve's finite field for the pr adopted. For example, a field would be a 254-bit integer when paired with the default backend that spans the Grumpkin curve. -Fields support integer arithmetic: +Fields support integer arithmetic and are often used as the default numeric type in Noir: ```rust fn main(x : Field, y : Field) { From 2c15822cf6c1f8e97ab04608cbdc24f9e8676226 Mon Sep 17 00:00:00 2001 From: Savio <72797635+Savio-Sou@users.noreply.github.com> Date: Thu, 26 Oct 2023 04:05:49 +0800 Subject: [PATCH 4/4] Update docs/docs/language_concepts/data_types/01_integers.md Co-authored-by: jfecher --- docs/docs/language_concepts/data_types/01_integers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/language_concepts/data_types/01_integers.md b/docs/docs/language_concepts/data_types/01_integers.md index 37f9ec7a7da..3a115f2fc23 100644 --- a/docs/docs/language_concepts/data_types/01_integers.md +++ b/docs/docs/language_concepts/data_types/01_integers.md @@ -15,7 +15,7 @@ keywords: An integer type is a range constrained field type. The Noir frontend currently supports unsigned, arbitrary-sized integer types. -> **Note:** When an integer is defined in Noir without a specific type, it would default to `u64`. +> **Note:** When an integer is defined in Noir without a specific type, it will default to `Field`. The one exception is for loop indices which default to `u64` since comparisons on `Field`s are not possible. An integer type is specified first with the letter `u`, indicating its unsigned nature, followed by its length in bits (e.g. `32`). For example, a `u32` variable can store a value in the range of