From 7952b48c46f3a41a9b076bec9f434bf91ff718b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Fri, 29 Sep 2023 16:15:01 +0200 Subject: [PATCH 1/5] Less complicated are_primes_below example --- src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 38c2341..637fb8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,13 +202,13 @@ pub const fn primes() -> [Underlying; N] { /// Sieve limited ranges of very large values /// ``` /// # use const_primes::are_prime_below; -/// const BIG_NUMBER: u64 = 5_000_000_000; -/// const SQRT_BIG_NUMBER: usize = 70711; // ceil(sqrt(BIG_NUMBER)) -/// const BIG_PRIME_STATUSES: [bool; SQRT_BIG_NUMBER] = are_prime_below(BIG_NUMBER); +/// const BIG_NUMBER: u64 = 5_000_000_031; +/// const CEIL_SQRT_BIG_NUMBER: usize = 70711; +/// const BIG_PRIME_STATUSES: [bool; CEIL_SQRT_BIG_NUMBER] = are_prime_below(BIG_NUMBER); /// assert_eq!( -/// BIG_PRIME_STATUSES[SQRT_BIG_NUMBER - 65..SQRT_BIG_NUMBER - 60], -/// // 4999999935 4999999936 4999999937 4999999938 4999999939 -/// [false, false, true, false, false], +/// BIG_PRIME_STATUSES[CEIL_SQRT_BIG_NUMBER - 3..], +/// // 5_000_000_028 5_000_000_029 5_000_000_030 +/// [false, true, false], /// ); /// ``` /// From 04f64112b97840a67536cafd6e4a7bb5b5a9c5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Fri, 29 Sep 2023 18:54:58 +0200 Subject: [PATCH 2/5] Spelling --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 637fb8d..995e50a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,7 +73,7 @@ /// The functions that return or take integers use this type. Currently `u32`. // Just change this to whatever unsigned primitive integer type you want and it should work as long as it has enough bits for your purposes (and you change the special case in isqrt). -// This is used since there is currenlty no way to be generic over types that can do arithmetic at compile time. +// This is used since there is currently no way to be generic over types that can do arithmetic at compile time. type Underlying = u32; mod imath; From fc916f2be97688ae1f50f36ddf40d8fe73a7d9a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Fri, 29 Sep 2023 18:55:24 +0200 Subject: [PATCH 3/5] Remove mention of isqrt --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 995e50a..5d38326 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,7 +72,7 @@ #![cfg_attr(not(test), no_std)] /// The functions that return or take integers use this type. Currently `u32`. -// Just change this to whatever unsigned primitive integer type you want and it should work as long as it has enough bits for your purposes (and you change the special case in isqrt). +// Just change this to whatever unsigned primitive integer type you want and it should work as long as it has enough bits for your purposes. // This is used since there is currently no way to be generic over types that can do arithmetic at compile time. type Underlying = u32; From e9fd132160861e98c3ea747ce3d0209ae4e94ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sun, 1 Oct 2023 16:18:31 +0200 Subject: [PATCH 4/5] Use larger upper value in are_prime_below_examples --- README.md | 8 ++++---- src/lib.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c5d678f..ce4b1cd 100644 --- a/README.md +++ b/README.md @@ -57,10 +57,10 @@ assert_eq!(PRIME_STATUS, [false, false, true, true, false, true, false, true, fa ``` or `are_prime_below` to compute the prime status of the `N` largest integers below a given value, ```rust -const N: usize = 1001; -const BIG_PRIME_STATUS: [bool; N] = are_prime_below(1_000_005); -// 1_000_002 1_000_003 1_000_004 -assert_eq!(BIG_PRIME_STATUS[998..], [false, true, false]); +const N: usize = 70711; +const BIG_PRIME_STATUS: [bool; N] = are_prime_below(5_000_000_031); +// 5_000_000_028 5_000_000_029 5_000_000_030 +assert_eq!(BIG_PRIME_STATUS[N - 3..], [false, true, false]); ``` and more! diff --git a/src/lib.rs b/src/lib.rs index 5d38326..9cad3a6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,10 +61,10 @@ //! or [`are_prime_below`] to compute the prime status of the `N` largest integers below a given value, //! ``` //! # use const_primes::are_prime_below; -//! const N: usize = 1001; -//! const BIG_PRIME_STATUS: [bool; N] = are_prime_below(1_000_005); -//! // 1_000_002 1_000_003 1_000_004 -//! assert_eq!(BIG_PRIME_STATUS[998..], [false, true, false]); +//! const N: usize = 70711; +//! const BIG_PRIME_STATUS: [bool; N] = are_prime_below(5_000_000_031); +//! // 5_000_000_028 5_000_000_029 5_000_000_030 +//! assert_eq!(BIG_PRIME_STATUS[N - 3..], [false, true, false]); //! ``` //! and more! From 970e12421329685d7be4c1d518a9c19f543f0be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sun, 1 Oct 2023 16:21:05 +0200 Subject: [PATCH 5/5] Update docstring of Underlying --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 9cad3a6..b83fc89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,7 +71,7 @@ #![forbid(unsafe_code)] #![cfg_attr(not(test), no_std)] -/// The functions that return or take integers use this type. Currently `u32`. +/// The type that Primes stores, and primes::() returns. Currently `u32`. // Just change this to whatever unsigned primitive integer type you want and it should work as long as it has enough bits for your purposes. // This is used since there is currently no way to be generic over types that can do arithmetic at compile time. type Underlying = u32;