Merge pull request #314 from JacksonUtsch/patch-1

Update Floating-Point 7 for compiler verification
This commit is contained in:
Sunface 2022-10-11 10:13:46 +08:00 committed by GitHub
commit 5f44f48eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -93,14 +93,19 @@ fn main() {
```rust,editable
// Replace ? with your answer
// Fill the blank to make it work
fn main() {
let x = 1_000.000_1; // ?
let y: f32 = 0.12; // f32
let z = 0.01_f64; // f64
assert_eq!(type_of(&x), "__".to_string());
println!("Success!");
}
fn type_of<T>(_: &T) -> String {
format!("{}", std::any::type_name::<T>())
}
```
8. 🌟🌟 Make it work in two distinct ways

View File

@ -64,10 +64,17 @@ fn main() {
7.
```rust
fn main() {
fn main() {
let x = 1_000.000_1; // f64
let y: f32 = 0.12; // f32
let z = 0.01_f64; // f64
assert_eq!(type_of(&x), "f64".to_string());
println!("Success!");
}
fn type_of<T>(_: &T) -> String {
format!("{}", std::any::type_name::<T>())
}
```
@ -140,4 +147,4 @@ fn main() {
println!("1 << 5 is {}", 1u32 << 5);
println!("0x80 >> 2 is 0x{:x}", 0x80u32 >> 2);
}
```
```