1 |
From 0d5196feadafa77c727f517d747ffcf3fd0e8ba9 Mon Sep 17 00:00:00 2001 |
From 0d5196feadafa77c727f517d747ffcf3fd0e8ba9 Mon Sep 17 00:00:00 2001 |
2 |
From: Michael Hudson-Doyle <michael.hudson@canonical.com> |
From: Michael Hudson-Doyle <michael.hudson@canonical.com> |
3 |
Date: Wed, 13 Mar 2019 15:55:30 +1300 |
Date: Wed, 13 Mar 2019 15:55:30 +1300 |
4 |
Subject: [PATCH] round result of (highest as f64).log(2.0) |
Subject: [PATCH] round result of (highest as f64).log(2.0) |
5 |
|
|
6 |
Even though (1024f64).log(2.0) has an exact, representable, value, with rustc 1.32 on i386 it comes out as +9.999999999999999985 with optimization enabled. And the rustc doesn't like having two defintions for U1024 etc. |
Even though (1024f64).log(2.0) has an exact, representable, value, with rustc 1.32 on i386 it comes out as +9.999999999999999985 with optimization enabled. And the rustc doesn't like having two defintions for U1024 etc. |
7 |
--- |
--- |
8 |
build/main.rs | 2 +- |
build/main.rs | 2 +- |
9 |
1 file changed, 1 insertion(+), 1 deletion(-) |
1 file changed, 1 insertion(+), 1 deletion(-) |
10 |
|
|
11 |
diff --git a/build/main.rs b/build/main.rs |
diff --git a/build/main.rs b/build/main.rs |
12 |
index 16b0ffe2f..b7939f993 100644 |
index 16b0ffe2f..b7939f993 100644 |
13 |
--- a/vendor/typenum/build/main.rs |
--- a/vendor/typenum/build/main.rs |
14 |
+++ b/vendor/typenum/build/main.rs |
+++ b/vendor/typenum/build/main.rs |
15 |
@@ -81,7 +81,7 @@ pub fn no_std() {} |
@@ -81,7 +81,7 @@ pub fn no_std() {} |
16 |
fn main() { |
fn main() { |
17 |
let highest: u64 = 1024; |
let highest: u64 = 1024; |
18 |
|
|
19 |
- let first2: u32 = (highest as f64).log(2.0) as u32 + 1; |
- let first2: u32 = (highest as f64).log(2.0) as u32 + 1; |
20 |
+ let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1; |
+ let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1; |
21 |
let first10: u32 = (highest as f64).log(10.0) as u32 + 1; |
let first10: u32 = (highest as f64).log(10.0) as u32 + 1; |
22 |
let uints = (0..(highest + 1)) |
let uints = (0..(highest + 1)) |
23 |
.chain((first2..64).map(|i| 2u64.pow(i))) |
.chain((first2..64).map(|i| 2u64.pow(i))) |