summaryrefslogtreecommitdiffstats
path: root/vendor/serde_json/src/lexical/small_powers.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/serde_json/src/lexical/small_powers.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/serde_json/src/lexical/small_powers.rs')
-rw-r--r--vendor/serde_json/src/lexical/small_powers.rs70
1 files changed, 70 insertions, 0 deletions
diff --git a/vendor/serde_json/src/lexical/small_powers.rs b/vendor/serde_json/src/lexical/small_powers.rs
new file mode 100644
index 000000000..219d82611
--- /dev/null
+++ b/vendor/serde_json/src/lexical/small_powers.rs
@@ -0,0 +1,70 @@
+// Adapted from https://github.com/Alexhuszagh/rust-lexical.
+
+//! Pre-computed small powers.
+
+// 32 BIT
+#[cfg(limb_width_32)]
+pub(crate) const POW5_32: [u32; 14] = [
+ 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625,
+ 1220703125,
+];
+
+#[cfg(limb_width_32)]
+pub(crate) const POW10_32: [u32; 10] = [
+ 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000,
+];
+
+// 64 BIT
+#[cfg(limb_width_64)]
+pub(crate) const POW5_64: [u64; 28] = [
+ 1,
+ 5,
+ 25,
+ 125,
+ 625,
+ 3125,
+ 15625,
+ 78125,
+ 390625,
+ 1953125,
+ 9765625,
+ 48828125,
+ 244140625,
+ 1220703125,
+ 6103515625,
+ 30517578125,
+ 152587890625,
+ 762939453125,
+ 3814697265625,
+ 19073486328125,
+ 95367431640625,
+ 476837158203125,
+ 2384185791015625,
+ 11920928955078125,
+ 59604644775390625,
+ 298023223876953125,
+ 1490116119384765625,
+ 7450580596923828125,
+];
+pub(crate) const POW10_64: [u64; 20] = [
+ 1,
+ 10,
+ 100,
+ 1000,
+ 10000,
+ 100000,
+ 1000000,
+ 10000000,
+ 100000000,
+ 1000000000,
+ 10000000000,
+ 100000000000,
+ 1000000000000,
+ 10000000000000,
+ 100000000000000,
+ 1000000000000000,
+ 10000000000000000,
+ 100000000000000000,
+ 1000000000000000000,
+ 10000000000000000000,
+];